diff options
author | Richard Biener <rguenther@suse.de> | 2016-03-04 08:31:19 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-03-04 08:31:19 +0000 |
commit | e9a35493b0811bd6dd2584dbe79e7e1dca4e1722 (patch) | |
tree | 16ceea36318b74b1bd15b4fc05467a8d8123a5eb /gcc | |
parent | 6a27431a5482e70110ff3487bd7c7a8e90fbad9c (diff) | |
download | gcc-e9a35493b0811bd6dd2584dbe79e7e1dca4e1722.zip gcc-e9a35493b0811bd6dd2584dbe79e7e1dca4e1722.tar.gz gcc-e9a35493b0811bd6dd2584dbe79e7e1dca4e1722.tar.bz2 |
re PR middle-end/70054 (GCC 6 gives a strict-aliasing warning on use of std::aligned_storage)
2016-03-04 Richard Biener <rguenther@suse.de>
PR c++/70054
* c-common.c (strict_aliasing_warning): Use alias_set_subset_of
instead of alias_sets_conflict_p.
* g++.dg/warn/Wstrict-aliasing-bogus-union-2.C: New testcase.
* gcc.dg/Wstrict-aliasing-struct-member.c: New testcase.
From-SVN: r233961
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-union-2.C | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c | 6 |
5 files changed, 33 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7a5e323..5c777b6 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-03-04 Richard Biener <rguenther@suse.de> + + PR c++/70054 + * c-common.c (strict_aliasing_warning): Use alias_set_subset_of + instead of alias_sets_conflict_p. + 2016-03-01 Marek Polacek <polacek@redhat.com> PR c++/69795 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 22ea7da..965cf49 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1568,7 +1568,7 @@ strict_aliasing_warning (tree otype, tree type, tree expr) alias_set_type set2 = get_alias_set (TREE_TYPE (type)); if (set1 != set2 && set2 != 0 - && (set1 == 0 || !alias_sets_conflict_p (set1, set2))) + && (set1 == 0 || !alias_set_subset_of (set2, set1))) { warning (OPT_Wstrict_aliasing, "dereferencing type-punned " "pointer will break strict-aliasing rules"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3627140..dfa91cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-03-04 Richard Biener <rguenther@suse.de> + + PR c++/70054 + * g++.dg/warn/Wstrict-aliasing-bogus-union-2.C: New testcase. + * gcc.dg/Wstrict-aliasing-struct-member.c: New testcase. + 2016-03-04 Dominik Vogt <vogt@linux.vnet.ibm.com> PR testsuite/69766 diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-union-2.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-union-2.C new file mode 100644 index 0000000..2b4895a --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-union-2.C @@ -0,0 +1,14 @@ +/* { dg-do compile { target c++11 } } */ +/* { dg-options "-Wstrict-aliasing=2 -O2 -Wall" } */ + +#include <type_traits> + +struct foo +{ + std::aligned_storage<sizeof(long), alignof(long)>::type raw; + + long& cooked() + { + return *static_cast<long*>(static_cast<void*>(&raw)); /* { dg-bogus "strict-aliasing" } */ + } +}; diff --git a/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c b/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c new file mode 100644 index 0000000..6c5e88d --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-aliasing-struct-member.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +struct S { int i; long l; }; +long x; +struct S foo () { return *(struct S *)&x; } /* { dg-warning "will break strict-aliasing" } */ |