Proposed resolution to aliasing issue.
Mark Mitchell
mark@codesourcery.com
Tue May 17 22:00:00 GMT 2005
Nathan Sidwell wrote:
> 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.
Excellent.
>>>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?
It wouldn't look like escape to (at least some compilers') optimizers
if, say, the front end folded it to a constant. So, I'm not sure how to
express what constitutes escape.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
More information about the Gcc
mailing list