This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
With: $ gcc --version gcc (Debian 4.3.1-2) 4.3.1 running on x86-64, the code below produces seemingly spurious warnings about integer overflow: $ LANG=C gcc -c b.c b.c: In function 'foo': b.c:3: warning: integer overflow in expression b.c:5: warning: integer overflow in expression $ cat b.c unsigned foo(int x) { return ((x & 1) | 2) & 0x80000000; return ((x & 2) | 2) & 0x80000000; return ((x & 4) | 2) & 0x80000000; }
Confirmed.
Testing a fix.
Caused by PR33691 fix btw.
Subject: Bug 37261 Author: jakub Date: Fri Aug 29 18:59:13 2008 New Revision: 139784 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139784 Log: PR c/37261 * fold-const.c (fold_binary): In (X | C1) & C2 canonicalization compute new & and | in type rather than TREE_TYPE (arg0). * gcc.dg/pr37261.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr37261.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 37261 Author: jakub Date: Fri Aug 29 19:08:18 2008 New Revision: 139786 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139786 Log: PR c/37261 * fold-const.c (fold_binary): In (X | C1) & C2 canonicalization compute new & and | in type rather than TREE_TYPE (arg0). * gcc.dg/pr37261.c: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/pr37261.c Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/fold-const.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed.