This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49705] New: -Wstrict-overflow should not diagnose unevaluated expressions
- From: "eggert at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Jul 2011 18:18:23 +0000
- Subject: [Bug c/49705] New: -Wstrict-overflow should not diagnose unevaluated expressions
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49705
Summary: -Wstrict-overflow should not diagnose unevaluated
expressions
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: eggert@gnu.org
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
I ran into this problem when compiling a test version of Emacs.
Here's a stripped-down version of the problem:
int
check_image_width (int width)
{
return (1 || width <= width + 2);
}
When compiled with "gcc -c -Wstrict-overflow -O2 t.c" the diagnostic is:
t.c:4:3: warning: assuming signed overflow does not occur when assuming that
(X + c) >= X is always true [-Wstrict-overflow]
This diagnostic is wrong, as the expression in question (width <=
width + 2) is unreachable. In the original source code the
expression is unreachable because the code is carefully checking for
integer overflow.
GCC should not diagnose potential integer overflow in unreachable
expressions, as that is a common idiom in code that is working correctly.