------- Comment #10 from rakdver at gcc dot gnu dot org 2007-02-05 21:45 ------- Hello,
(In reply to comment #8) > (In reply to comment #1) > > With -funsafe-loop-optimizations we remove them. > > Using -Wunsafe-loop-optimizations, we get: > > t.c:2: warning: cannot optimize loop, the loop counter may overflow > > If the loop counter will overflow for signed types, that is undefined and > we should do it no matter what unless -fwrapv is turned on. actually, the warning is missleading here. The problem is that the number of iterations of this loop is ((unsigned) b - (unsigned) a + 3) / 4 but this formula does not work if (unsigned) b - (unsigned) a + 3 overflows, which is what we fail to verify. The obvious-looking solution is to use formula 1 + ((unsigned) b - (unsigned) a -1) / 4 that does not suffer from this problem. I tried that, there are some problems with this as well (but I forgot what the problems are, so I will need to check again). -- rakdver at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |rakdver at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2005-08-12 19:10:31 |2007-02-05 21:45:12 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23361