This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix C++ strict-aliasing issues with memcpy folding
On Wed, Apr 14, 2010 at 11:39 PM, Jason Merrill <jason@redhat.com> wrote:
> On 04/14/2010 05:38 PM, Jason Merrill wrote:
>>
>> On 04/14/2010 05:23 PM, Richard Guenther wrote:
>
>>> Earlier you were arguing that storing the float into the union
>>> is ok because there's a character array member inside.
>>
>> As in this testcase? Yes, I believe so. And the float-ness transfers to
>> 'b' because union assignment is equivalent to memcpy.
>
> ...and so your point is that we need to give the union alias set zero in
> order to reflect that. ?I see.
Yes. Though I'm not 100% sure anymore. There seems to be a
inconsistency between alias_sets_conflict_p which wouldn't require
that (because the char member effectively accomplishes it - though
then there's no difference to assigning alias-set zero to it) and
alias_set_subset_of which would require it (because a char member
isn't the same as assigning alias-set zero to it). An inconsistency
that should be fixed - but maybe somebody remembers the
intent. I'd do
Index: gcc/alias.c
===================================================================
--- gcc/alias.c (revision 157963)
+++ gcc/alias.c (working copy)
@@ -427,7 +427,7 @@ alias_sets_conflict_p (alias_set_type se
/* See if the first alias set is a subset of the second. */
ase = get_alias_set_entry (set1);
if (ase != 0
- && (ase->has_zero_child
+ && ((ase->has_zero_child && set2 == 0)
|| splay_tree_lookup (ase->children,
(splay_tree_key) set2)))
return 1;
@@ -435,7 +435,7 @@ alias_sets_conflict_p (alias_set_type se
/* Now do the same, but with the alias sets reversed. */
ase = get_alias_set_entry (set2);
if (ase != 0
- && (ase->has_zero_child
+ && ((ase->has_zero_child && set1 == 0)
|| splay_tree_lookup (ase->children,
(splay_tree_key) set1)))
return 1;
making alias_sets_conflict_p equivalent to
alias_sets_must_conflict_p (set1, set2) || alias_set_subset_of (set1, set2)
|| alias_set_subset_of (set2, set1)
which requires somehow making the copy use alias-set zero - either
by explicitly using memcpy or by assigning alias-set zero to the
union itself.
Richard.
> Jason
>