g++ and aliasing bools

Paolo Carlini pcarlini@unitus.it
Thu Jan 24 15:08:00 GMT 2002


Daniel Berlin wrote:

> I'm confused as to why you think it's such a tricky thing to do C++
> aliasing that it requires any kind of formal sketch of a proof.
> I've read about 6 papers now on aliasing and static type determination in
> C++, and all just treat them as C structs that contain other C structs,
> with the special case that virtual bases are unions.
> Isn't this the correct way to do it?
> Other than virtual bases, don't the addresses of each subobject, and
> thus, their members, have to be different?
> The draft standard (I don't feel like opening the formal standard, i'm
> not near a graphical workstation of any kind right now) says
> " A base class subobject may be of zero size  (_class_);
>    however,  two subobjects that have the same class type and that belong
>    to the same most derived object must not  be  allocated  at  the  same
>    address (_expr.eq_).  ]"
>
> Doesn't this mean that excluding the virtual base class case, we could
> simply treat them as structs with other structs embedded in them (Which is
> already an improvement over what we have now)
> Or are all of the papers i've read on the subject just not being
> compliant, and getting lucky?
>
> It's also interesting that it appears pro64 simply removed that check, and
> calls record_component_aliases.
>
> --Dan

As a passionate supporter of g++, trying to do my best (in the time allowed by
my work) to help the project, I'd like to express my profound sympathy to Dan's
point of view.

I would really like to see g++ doing better in C++-aliasing sensitive codes
(i.e., Haney Speed) and I believe that any effort in this area should be
supported and encouraged as much as possible.

Dan, could you please point me (privately if you prefer) to some of those
papers?

Thanks,
Paolo.




More information about the Gcc mailing list