This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/48022] New: [4.6 Regression] -Wstrict-overflow warning on code that doesn't have overflows
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 7 Mar 2011 16:01:42 +0000
- Subject: [Bug tree-optimization/48022] New: [4.6 Regression] -Wstrict-overflow warning on code that doesn't have overflows
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48022
Summary: [4.6 Regression] -Wstrict-overflow warning on code
that doesn't have overflows
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jakub@gcc.gnu.org
int
foo (const char *x)
{
unsigned long l = 1;
const unsigned char *s = (const unsigned char *) (const char *) (x);
int r = s[0] - ((const unsigned char *) (const char *) ("/"))[0];
if (l > 0 && r == 0)
r = (s[1] - ((const unsigned char *) (const char *) ("/"))[1]);
return r;
}
gets at -O2 on x86_64-linux
warning: assuming signed overflow does not occur when changing X +- C1 cmp C2
to X cmp C1 +- C2 [-Wstrict-overflow]
This is simplified return strcmp (path, "/"); when using glibc <string.h>
strcmp macro.
The warning started with
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161655