diff options
author | Richard Biener <rguenther@suse.de> | 2016-06-29 07:30:31 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-06-29 07:30:31 +0000 |
commit | 4aa83879c93d2367f5245c94bd2f12c19f486dae (patch) | |
tree | 29eb8891c24a3daecbf68e50445cf77606b498d4 /gcc/alias.c | |
parent | 36088299955f95ab58a5758cba2f29b84c8fbfbc (diff) |
re PR middle-end/71002 (-fstrict-aliasing breaks Boost's short string optimization implementation)
2016-06-29 Richard Biener <rguenther@suse.de>
PR middle-end/71002
* alias.c (component_uses_parent_alias_set_from): Handle
type punning through union accesses by using the union alias set.
* gimple.c (gimple_get_alias_set): Remove union type punning case.
c-family/
* c-common.c (c_common_get_alias_set): Remove union type punning case.
fortran/
* f95-lang.c (LANG_HOOKS_GET_ALIAS_SET): Remove (un-)define.
(gfc_get_alias_set): Remove.
* g++.dg/torture/pr71002.C: Adjust testcase.
From-SVN: r237839
Diffstat (limited to 'gcc/alias.c')
-rw-r--r-- | gcc/alias.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/alias.c b/gcc/alias.c index 1e4c4d19e69..dd1dfd38920 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -619,6 +619,14 @@ component_uses_parent_alias_set_from (const_tree t) case COMPONENT_REF: if (DECL_NONADDRESSABLE_P (TREE_OPERAND (t, 1))) found = t; + /* Permit type-punning when accessing a union, provided the access + is directly through the union. For example, this code does not + permit taking the address of a union member and then storing + through it. Even the type-punning allowed here is a GCC + extension, albeit a common and useful one; the C standard says + that such accesses have implementation-defined behavior. */ + else if (TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == UNION_TYPE) + found = t; break; case ARRAY_REF: |