http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58926
Bug ID: 58926
Summary: -Wstrict-overflow unwanted warning comparing variables
initialized from one of static duration
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabe.jones at ni dot com
The following code produces a warning when compiled -O2 -Wstrict-overflow with
gcc 4.8.1:
int k = 0;
int main(void)
{
int i = k++, j = k;
return (j >= i);
}
> gcc -Wstrict-overflow -O2 main.cc
main.cpp: In function 'int func()':
main.cpp:6:13: warning: assuming signed overflow does not occur when assuming
that (X + c) >= X is always true [-Wstrict-overflow]
return (j >= i);
^
^