On Thu, 2005-05-12 at 10:01 -0700, Mark Mitchell wrote:
> Theodore Papadopoulo wrote:
> > On Wed, 2005-05-11 at 15:30 -0700, Mark Mitchell wrote:
> > 
> > Given the following:
> > 
> > struct A {
> >     B& b1;
> >         B& b2;
> >   const B& b3;
> > 
> >   A(B& b): b1(b),b2(b),b3(b) { }
> > };
> > 
> > Is the compiler allowed to suppress b2 and/or b3 from the layout of the
> > object. The next question comes when b1,b2 and b3 are in various places
> > in an inheritance path, would it be allowed to only keep the first
> > reference in this path (provided of course that it can be proved that
> > all references are bound to the same object).
> 
> Tricky!  Because you can't get the address of the reference, or form a 
> pointer-to-member, it might be valid to do the optimization you suggest. 
>     Then again, there might be something lurking that I'm not thinking of.

> In any case, nobody does that optimization, and it would break the ABI.

Yeah I understand that. But one day I might want to evaluate the impact
of this (multiple references) in some of my codes (which of course
include many arrays which is where I would like to avoid some memory
explosion). Obviously, it is always possible to avoid it using simple
programming tricks but this somehow is less clean from the programmer
POV.

Anyway thank's a lot for the answer...

        Theo.

Reply via email to