On Tue, Jul 22, 2014 at 5:17 PM, Jan Hubicka <hubi...@ucw.cz> wrote:
>> I don't see why
>>
>> long x[1024];
>>
>> Q *q = new (x) Q;
>> q->~Q ();
>> new (x) T;
>>
>> would be invalid.  I also don't see why
>>
>> Q q;
>> q.~Q ();
>> new (&q) T;
>>
>> would be.  Object lifetime is precisely specified and I don't see where it is
>> tied to (static) storage lifetime.
>
> This is precisely the testcase I posted on beggining of this thread.
>
> I do not see how the testcases can work with aliasing rules in the case Q's 
> and T's
> memory is known to not alias.

It works because of the well-defined memory model (with regarding to
TBAA) in the middle-end.  Every store changes the dynamic type of
a memory location which means that you can only use TBAA for
true-dependence checks (not anti-dependence or write-dependence
checks).

That has been the way we operate since GCC 4.3 (if I remember
correctly).  That's also the reason we don't have to special-case
unions in any tricky way (yeah, we still do - because of that
type-punning special case and RTL alias analysis not dealing with it).

> Either we need to define what is and is not supported or go for speculative 
> devirt more often.

The GCC middle-end (which also has to deal with cross-language
cases!) has this specified very clearly.

Richard.

> Honza

Reply via email to