This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Proposed resolution to aliasing issue.
Mark Mitchell wrote:
> Will the UK committee open a DR for this? Or, would you care to send
> mail to Steve Adamczyk about it?
this can be done. I shall wait until the minutes have been written up.
>
>> The observation was made that if A is non-POD, one cannot play offsetof
>> tricks to get from A::a to A::b, so the optimization is safe on non-PODs.
>> (Of course one would have to prove the address of 'v' did not escape,
>> so I guess the ctor and dtor would need to be trivial or visible.)
>
>
> I argued last week that this was not in fact true, in that you can do:
>
> ptrdiff_t x = &v.b - &v.a;
>
> and then use that instead of "offsetof (Foo, b) - offsetof (Foo, a)".
Does not '&v.b - &v.a' cause the address to 'escape', and therefore
lock down the structure? If it doesn't, how hard would it be to
make that DTRT?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk