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.
p.
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.
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.
masarati@aero.polimi.it writes:
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.
True enough, but since the subject is killing harmless warnings: I've seen warnings when the compiler decides to promote a constant without 'U' to unsigned.