Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 37261
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Jakub Jelinek <jakub@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Roland Dreier <roland@digitalvampire.org>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 37261 depends on: Show dependency tree
Show dependency graph
Bug 37261 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-08-29 11:55 Opened: 2008-08-27 23:45
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;
}

------- Comment #1 From Richard Guenther 2008-08-28 09:16 -------
Confirmed.

------- Comment #2 From Jakub Jelinek 2008-08-29 11:55 -------
Testing a fix.

------- Comment #3 From Jakub Jelinek 2008-08-29 12:23 -------
Caused by PR33691 fix btw.

------- Comment #4 From Jakub Jelinek 2008-08-29 19:00 -------
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

------- Comment #5 From Jakub Jelinek 2008-08-29 19:09 -------
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

------- Comment #6 From Jakub Jelinek 2008-08-29 19:11 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug