https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79671

--- Comment #50 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #44)
> Created attachment 41048 [details]
> trial patch
> 
> Does this fix the issue?  I don't have an ARM setup handy for testing.

I should.

Note that what changed with GCC 7 is only that unions with char members
no longer behave as alias-set zero but 12.8/16 talks about all unions,
not just unions with char members.

Now I read comment#14 as that _only_ char[] members (of structs or unions)
may ever "contain" different dynamic types.  Any pointer to a part of
the standard that singles out char[] that way?

Note your proposed patch will weaken TBAA for all structs/unions with a char
(array) member for the task of aggregate copying.  Might not be too bad
as open-coding memberwise copy would expose alias-set zero writes as well.

The change that exposed char[] union handling differences is

r223126 | rguenth | 2015-05-13 12:53:42 +0200 (Wed, 13 May 2015) | 10 lines

2015-05-13  Richard Biener  <rguent...@suse.de>

        PR middle-end/66110
        * alias.c (alias_sets_conflict_p): Do not treat has_zero_child
        specially.

which is to avoid having aggregates with char members aliasing with everything,
instead they only alias with alias subsets (including explicit zero).

So if you take the original reduced testcase in this PR and exchange the
char[] array inside the union with a int[] array then the "bug" should trigger
with older GCC as well.  That is, GCC never implemented 12.8/16.

Reply via email to