This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH] Fix optimization regression in constant folder


> > The premise is that the behavior of the program is undefined in this case.
> 
> Sure, but only GCC itself creates arithmetic in types with TYPE_IS_SIZETYPE
> set.  Do you guarantee we that those never result in overflow?

Again, we don't have to.  We just have to guarantee that it would only
overflow if ANY form of the computation would overflow, meaning that
the program is undefined.

The issue here is arithmetic of the form (A + B) + C where A and B both
have large absolute values but opposite signs, so reassociating it as
A + (B + C) might overflow were the former wouldn't.  But that sort of thing
just doesn't come up in size computations of objects: any negative values
are known to be very small.


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