[Date Prev][Date Next]
Re: Signedness issue in utf-8 code?
> In libldap/utf-8-conv.c:194
> if( wchar < 0x80000000 )
> I get a warning about signed/unsigned comparison. What seems to happen is
> that wchar (which is of type wchar_t) is a signed integer (on my i386,it's
> a 4 byte int) and thus it's always < 0x80000000 by definition. ANSI C
> converts 0x80000000 to unsigned, thus the warning.
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.