Using gcc version 4.3.1 (Debian 4.3.1-9) on amd64 I get a warning I shouldn't: $ gcc -O2 -Wstrict-overflow=2 testcase-min.i -c testcase-min.i: In function cli_scanrar: testcase-min.i:40: warning: assuming signed overflow does not occur when simplifying conditional to constant
At line 40 there is this (ret is int, but it only gets values assigned, no arithmetic is performed on it) if(ret == 2) ret = 0; I am attaching the reduced testcase. More system info: $ uname -a Linux lightspeed2 2.6.26-1-amd64 #1 SMP Fri Aug 8 13:17:41 UTC 2008 x86_64 GNU/Linux $ gcc -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.1-9' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-cld --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.3.1 (Debian 4.3.1-9) -- Summary: false positive with -Wstrict-overflow=2 on code not involving signed overflow Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: edwintorok at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37178