Bug in loop optimize (invalid postinc to preinc transformation)
Andreas Schwab
schwab@suse.de
Sun Dec 31 08:25:00 GMT 2000
Jamie Lokier <egcs@tantalophile.demon.co.uk> writes:
|> 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?
Comparing pointers that don't point to the same (part of) object is
undefined.
Andreas.
--
Andreas Schwab "And now for something
SuSE Labs completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
More information about the Gcc
mailing list