This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix C++ strict-aliasing issues with memcpy folding


On Tue, Feb 2, 2010 at 7:58 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * Gabriel Dos Reis:
>
>> On Sun, Jan 24, 2010 at 6:14 PM, Mark Mitchell <mark@codesourcery.com> wrote:
>>
>>> In that case, I don't think that "following the standard" is a useful
>>> thing to try to do. ?"Fix the standard" might be useful, of course.
>>> But, as an implementor, I think we should do something sensible. ?I'm
>>> very bothered by the idea that:
>>>
>>> ?int i;
>>> ?int *p = &i;
>>> ?// something
>>> ?*p = 3;
>>>
>>> might be invalid. ?That seems very wrong.
>>
>> I cannot find any text that says that if 'p' still points
>> to the storage of 'i', then the above is invalid.
>
> "something" could involve a placement new, then you're reusing the
> storage and the code turns invalid.

"something" could use placement new to construct a new int object, therefore
ending the lifetime of the previous object; yes.  But, I believe you need at
the minimum to invoke some implementation-defined aspects/guarantees to
construct a float at 'p', and pretend that now 'i' is just a storage for float.

>
> I think C++ is simply not amenable to type-based alias analysis. 8-)
>

that would be against its spirit :-)

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]