[Bug c/30730] New: -Wunsafe-loop-optimizations gives too many warnings
roland dot illig at gmx dot de
gcc-bugzilla@gcc.gnu.org
Wed Feb 7 20:25:00 GMT 2007
$ cat > warning.c
#if 0
gcc-4.1.1 -c -Os warning.c -Wunsafe-loop-optimizations
exit 0
#endif
void foo(unsigned int n)
{
while (n > 10)
n -= 2;
}
^D
$ sh warning.c
warning.c: In function 'foo':
warning.c:8: warning: cannot optimize loop, the loop counter may overflow
warning.c:8: warning: cannot optimize loop, the loop counter may overflow
...
This warning seems to be wrong to me, or at least badly worded. Furthermore,
gcc should notice that the condition states "n >= 10", and n is decremented by
only 2 in each iteration, so the loop _will_ terminate. There won't be any
overflow.
It would also be nice if this warning were only printed once instead of 9
times.
--
Summary: -Wunsafe-loop-optimizations gives too many warnings
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: roland dot illig at gmx dot de
GCC build triplet: any
GCC host triplet: any
GCC target triplet: any
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30730
More information about the Gcc-bugs
mailing list