This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in loop optimize (invalid postinc to preinc transformation)


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]