The following code compiled as C++ (does not happen when compiled as C), issues a wrong warning:
void test() { unsigned int i = 0; int val = i ? i : -1; } $ gcc -c test.cpp test.cpp: In function `void test()': test.cpp:4: warning: converting of negative value `-0x000000001' to `unsigned int' My GCC version: Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.2 (mingw-special) I does also happen with MinGW GCC 3.3.3 and 4.0.0 (20040925) and linux GCC 3.2. -- Summary: wrong warning when assigning negative value to int Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: oliverst at online dot de CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19437