This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix C++ strict-aliasing issues with memcpy folding
- From: Jason Merrill <jason at redhat dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Michael Matz <matz at suse dot de>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Richard Guenther <rguenther at suse dot de>, Richard Guenther <richard dot guenther at gmail dot com>, Paolo Bonzini <bonzini at gnu dot org>, gcc-patches at gcc dot gnu dot org, Diego Novillo <dnovillo at google dot com>
- Date: Wed, 14 Apr 2010 15:34:50 -0400
- Subject: Re: [PATCH] Fix C++ strict-aliasing issues with memcpy folding
- References: <alpine.LNX.email@example.com> <Pine.LNX.firstname.lastname@example.org> <4B697B53.email@example.com> <Pine.LNX.firstname.lastname@example.org> <email@example.com> <Pine.LNX.firstname.lastname@example.org> <email@example.com> <Pine.LNX.firstname.lastname@example.org> <email@example.com> <Pine.LNX.firstname.lastname@example.org> <email@example.com> <Pine.LNX.firstname.lastname@example.org> <4B69CB11.email@example.com>
What's the status of these issues, now that 4.5 has branched?
On 02/03/2010 02:14 PM, Mark Mitchell wrote:
This all depends on the fact that mem is an array of characters. An
array of characters is always (in my model) understood to be a blob of
bytes in which you can create and destroy other objects. The fact that
it's a non-static data member of X is not important. My feeling is that
an array of characters is implicitly a union of the array of characters
and whatever type is created via placement new.
I agree with this.
In an earlier message in the thread Richard quoted the C standard:
6.5/6 'If a value is copied into an object having no
declared type using memcpy or memmove, or is copied as an
array of character type, then the effective type of the
modified object for that access and for subsequent accesses that
do not modify the values is the effective type of the object
from which the value is copied, if it has one'.
Note "or is copied as an array of character type". Since struct
assignment is defined as memberwise assignment and union assignment is
defined as assignment of the value representation (which is an array of
unsigned char), such an assignment should transfer the effective type of
a subobject that completely overlaps either a union or an array of