[PATCH] Fix optimization regression in constant folder

Richard Guenther richard.guenther@gmail.com
Thu Oct 11 15:10:00 GMT 2007


On 10/11/07, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Wed, 10 Oct 2007, Mark Mitchell wrote:
>
> > 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 was my understanding during this whole thread, that this sizetype with
> the funny guarantees only can come out of the Ada frontend (and therefore
> needs to be dealt with in the middle end), and should never be produced by
> the other languages, in particular not C or C++.  I realize that this
> currently is not the case (i.e. C/C++ do produce TYPE_IS_SIZETYPE types)
> and my understanding was that this actually is a bug.
>
> It's obvious that C and C++ could _not_ make use of a type with the
> properties that Eric and Richard K. proposed, and as I don't know Ada well
> enough I simply assumed they know what they want and can ensure the
> guarantees they need for that type due to magic restrictions of the
> language itself.
>
> My understanding is supported by the comment in front of the
> TYPE_IS_SIZETYPE definition in tree.h where it explicitely mentions that
> size_t should not have this flag set.

It's used for "internal" calculations in C++ as well.  Which, as I said at the
very beginning in this thread makes it hard to argue that such a type is more
than a usual integral type (with the only exception that possibly even signed
sizetypes wrap).

Richard.



More information about the Gcc-patches mailing list