[Bug other/28230] -O2 -fwrapv miscompiles gcc, binutils, gzip.

pluto at agmk dot net gcc-bugzilla@gcc.gnu.org
Wed Sep 20 23:31:00 GMT 2006



------- Comment #10 from pluto at agmk dot net  2006-09-20 23:31 -------
i have a reduced testcase:

$ cat tmp.c
void foo( unsigned long bb, unsigned short tn, unsigned e, unsigned* w )
{
        unsigned n = tn + bb;
        do {
                e = (e > n) ? e : *w;
                n -= (e > n) ? n : e;
                if (*w)
                        *w = 0;
        } while ( n );
}
int main()
{
        unsigned w = 0;
        foo( 0, 0, 0, &w );
        return 0;
}

with `-O1 -fwrapv -ftree-vrp' gcc-4.2 produces an infinite loop.
without -ftree-vrp it reaches an exit point. gcc-4.1 works fine
in both cases.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28230



More information about the Gcc-bugs mailing list