[PATCH] Fix optimization regression in constant folder

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Wed Oct 10 22:43:00 GMT 2007


> I've seen people declare C++ objects that map on to huge chunks of the
> entire object space, e.g.:
> 
>   class Everything {
>     char [2 * 1024 * 1024 * 1024];
>   };
> 
> Then, all you need is a derived class, and the offsets from that to the
> base class will be very large negative numbers.  I'm not sure whether we
> give those ptrdiff_t type or a signed sizetype type -- but if we're
> going to have a special type for sizetype, this ought to be one.
> 
> Where does this "negative values are always small" guarantee come from?

It wasn't a "guarantee", more a statement of typical usage, but you're
right that they can be large in some cases.  However, I still believe that
even in those cases, the thing we DO have to guarantee is indeed true: that
all the numbers involved have the property that they are well-behaved
enough that unless there is a too-large item, so an overflow will occur, no
reassociation will produce an overflow.



More information about the Gcc-patches mailing list