User account creation filtered due to spam.

Bug 37261 - [4.3/4.4 Regression] Spurious (?) "integer overflow in expression" warnings
Summary: [4.3/4.4 Regression] Spurious (?) "integer overflow in expression" warnings
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.1
: P3 minor
Target Milestone: 4.3.3
Assignee: Jakub Jelinek
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2008-08-27 23:45 UTC by Roland Dreier
Modified: 2008-12-18 22:18 UTC (History)
2 users (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work: 4.2.4
Known to fail: 4.3.1
Last reconfirmed: 2008-08-29 11:55:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Dreier 2008-08-27 23:45:19 UTC
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 Richard Biener 2008-08-28 09:16:34 UTC
Confirmed.
Comment 2 Jakub Jelinek 2008-08-29 11:55:55 UTC
Testing a fix.
Comment 3 Jakub Jelinek 2008-08-29 12:23:32 UTC
Caused by PR33691 fix btw.
Comment 4 Jakub Jelinek 2008-08-29 19:00:35 UTC
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 Jakub Jelinek 2008-08-29 19:09:41 UTC
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 Jakub Jelinek 2008-08-29 19:11:45 UTC
Fixed.