stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r647698 - /stdcxx/trunk/include/loc/_ctype.h
Date Fri, 18 Apr 2008 16:53:08 GMT
Farid,

This change causes nearly 3000 lines of new HP aCC warnings
in our nightly builds, and a similar number for gcc. It's
making it quite difficult to clean up other diagnostics
(STDCXX-695 and STDCXX-726). Can you please either fix the
code or revert the change ASAP?

Martin

Martin Sebor wrote:
> faridz@apache.org wrote:
>> Author: faridz
>> Date: Mon Apr 14 01:38:10 2008
>> New Revision: 647698
>>
>> URL: http://svn.apache.org/viewvc?rev=647698&view=rev
>> Log:
>> 2008-04-14 Farid Zaripov <farid_zaripov@epam.com>
>>
>>     STDXX-854
>>     * include/loc/_ctype.h (narrow): Don't cast __c to unsigned char,
>>     use __c as index in _C_narrow_tab.
> 
> This change is causing warnings in HP aCC builds:
> 
> "$TOPDIR/include/loc/_ctype.h", line 545: warning #2186-D:
>           pointless comparison of unsigned integer with zero
>       if (   0 <= __c
>                ^
> 
> ""$TOPDIR/include/loc/_ctype.h", line 555: warning #2186-D:
>           pointless comparison of unsigned integer with zero
>       if (   0 <= __c
>                ^
> 
> I don't see how we're going to be able to silence these kinds
> of signed/unsigned warnings without a cast. Could we fix this
> by casting __c to the unsigned form of wchar_t's underlying
> type and keeping the original code, something like:
> 
>   #if _RWSTD_WCHAR_MIN < 0
>      // avoid sign extension when converting wchar_t
>   #  if _RWSTD_CHAR_SIZE == _RWSTD_WCHAR_SIZE
>     typedef unsigned char _UIntT;
>   #  elif _RWSTD_SHRT_SIZE == _RWSTD_WCHAR_SIZE
>     typedef unsigned short _UIntT;
>   #  elif _RWSTD_INT_SIZE == _RWSTD_WCHAR_SIZE
>     typedef unsigned int _UIntT;
>   #  else
>     typedef _RWSTD_SIZE_T _UIntT;
>   #  endif
>   #else
>     typedef _RWSTD_SIZE_T _UIntT;
>   #endif
> 
>   const _RWSTD_SIZE_T __inx = _RWSTD_STATIC_CAST (_UIntT, __c);
> 
>   if (   __inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
>        && _C_narrow_tab [__inx])
>         return _C_narrow_tab [__inx];
> 
> I suspect that there are other places in the library where we need
> to play tricks like this so we might even want to consider adding
> a general purpose config macro/typedef for this. wint_t isn't good
> enough because it might be wider than wchar_t. How does
> _RWSTD_UWCHAR_INT_T sound?
> 
> Martin
> 
>>
>> Modified:
>>     stdcxx/trunk/include/loc/_ctype.h
>>
>> Modified: stdcxx/trunk/include/loc/_ctype.h
>> URL: 
>> http://svn.apache.org/viewvc/stdcxx/trunk/include/loc/_ctype.h?rev=647698&r1=647697&r2=647698&view=diff

>>
>> ============================================================================== 
>>
>> --- stdcxx/trunk/include/loc/_ctype.h (original)
>> +++ stdcxx/trunk/include/loc/_ctype.h Mon Apr 14 01:38:10 2008
>> @@ -541,20 +541,21 @@
>>  inline char
>>  ctype<wchar_t>::narrow (char_type __c, char __dfault) const
>>  {
>> -    const _RWSTD_SIZE_T __inx = _RWSTD_STATIC_CAST (unsigned char, __c);
>> -
>>      // optimize away all but the first call to the virtual do_widen()
>> -    if (   __inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
>> -        && _C_narrow_tab [__inx])
>> -        return _C_narrow_tab [__inx];
>> +    if (   0 <= __c
>> +        && __c < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
>> +        && _C_narrow_tab [__c])
>> +        return _C_narrow_tab [__c];
>>  
>>      // template argument provided to work around an HP aCC bug (PR 
>> #27087)
>>      ctype<wchar_t>* const __self = _RWSTD_CONST_CAST 
>> (ctype<wchar_t>*, this);
>>  
>>      const char __ch = do_narrow (__c, __dfault);
>>  
>> -    if (__inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab && __ch

>> != __dfault)
>> -        __self->_C_narrow_tab [__inx] = __ch;
>> +    if (   0 <= __c
>> +        && __c < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
>> +        && __ch != __dfault)
>> +        __self->_C_narrow_tab [__c] = __ch;
>>  
>>      return __ch;
>>  }
>>
>>
> 



Mime
View raw message