public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30730]  New: -Wunsafe-loop-optimizations gives too many warnings
@ 2007-02-07 20:25 roland dot illig at gmx dot de
  2007-02-08  9:34 ` [Bug tree-optimization/30730] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: roland dot illig at gmx dot de @ 2007-02-07 20:25 UTC (permalink / raw)
  To: gcc-bugs

$ 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-07-10  8:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-07 20:25 [Bug c/30730] New: -Wunsafe-loop-optimizations gives too many warnings roland dot illig at gmx dot de
2007-02-08  9:34 ` [Bug tree-optimization/30730] " rguenth at gcc dot gnu dot org
2007-02-08  9:38 ` rakdver at gcc dot gnu dot org
2007-03-14  0:39 ` rakdver at gcc dot gnu dot org
2007-07-10  8:31 ` spop at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).