From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Lokier To: Alexandre Oliva Cc: Peter Osterlund , David Korn , "'Denis Chertykov'" , gcc@gcc.gnu.org Subject: Re: Bug in loop optimize (invalid postinc to preinc transformation) Date: Wed, 27 Dec 2000 22:24:00 -0000 Message-id: <20001228071627.C4578@thefinal.cern.ch> References: <718D38CAB6E0D011B2C90060970C28A5642545@EXCHANGESERVER> X-SW-Source: 2000-12/msg00790.html Alexandre Oliva wrote: > > Compiling without optimization indicates that the compiler is > > transforming (p++ < x) into (++p < (x+1)), even when not optimizing. > > This transformation is incorrect because x+1 wraps around. > > Overflow invokes undefined behavior. Since incrementing p in this > case involves overflow, I think the transformation is ok, as far as > undefined behavior goes. Overflow of unsigned integers has defined behaviour -- they wrap. The question is, what rule applies to pointer comparisons? -- Jamie