[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Signedness issue in utf-8 code?



> masarati@aero.polimi.it writes:
>> That code is only in use when sizeof(wchar_t) >= 4.  The C library
>> standard mandates wchar_t to be integer, thus signed.  If I promote
>> 0x80000000 to 0x80000000LL, when sizeof(wchar_t) == 4, like in my case,
>> the test will always be true, and the compiler will complain about the
>> test always being true.  Everything would be fine otherwise.
>
> Now C90 compilers get to warn about long long instead.
> With the new #if SIZEOF_WCHAR_T > 4, "if(wchar < (wchar_t)0x80000000UL)"
> should be sufficient.

0x80000000UL is == 0x80000000, as costants >= 0xffffffff are automatically
promoted to unsigned.

p.