re PR c/70143 (false strict-aliasing warning)

2016-03-09  Richard Biener  <rguenther@suse.de>

	c-family/
	PR c/70143
	* c-common.c (strict_aliasing_warning): Add back
	alias_sets_conflict_p check.

	* gcc.dg/Wstrict-aliasing-bogus-upcast.c: New testcase.
	* gcc.dg/Wstrict-aliasing-struct-with-char-member.c: Likewise.
	* gcc.dg/Wstrict-aliasing-struct-member.c: Remove again.

From-SVN: r234084
This commit is contained in:
Richard Biener 2016-03-09 14:01:16 +00:00 committed by Richard Biener
parent 8e80c4d476
commit c06d25bb33
6 changed files with 49 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2016-03-09 Richard Biener <rguenther@suse.de>
PR c/70143
* c-common.c (strict_aliasing_warning): Add back
alias_sets_conflict_p check.
2016-03-08 Jason Merrill <jason@redhat.com>
* c-opts.c (set_std_cxx1z): Don't enable concepts.

View file

@ -1568,7 +1568,9 @@ 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_set_subset_of (set2, set1)))
&& (set1 == 0
|| (!alias_set_subset_of (set2, set1)
&& !alias_sets_conflict_p (set1, set2))))
{
warning (OPT_Wstrict_aliasing, "dereferencing type-punned "
"pointer will break strict-aliasing rules");

View file

@ -1,3 +1,10 @@
2016-03-09 Richard Biener <rguenther@suse.de>
PR c/70143
* gcc.dg/Wstrict-aliasing-bogus-upcast.c: New testcase.
* gcc.dg/Wstrict-aliasing-struct-with-char-member.c: Likewise.
* gcc.dg/Wstrict-aliasing-struct-member.c: Remove again.
2016-03-09 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/vect/bb-slp-34.c: Really don't xfail on aarch64-*-*,

View file

@ -0,0 +1,17 @@
/* { dg-do compile } */
/* { dg-options "-O2 -Wall" } */
struct a {
int i;
};
struct b {
struct a a;
int j;
};
int main(void)
{
static struct b b;
struct a *ap=(struct a *)&b;
return ((struct b *)&ap->i)->j; /* { dg-bogus "will break strict-aliasing" } */
}

View file

@ -1,6 +0,0 @@
/* { 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" } */

View file

@ -0,0 +1,16 @@
/* { dg-do compile } */
/* { dg-options "-O2 -Wall" } */
struct a {
int i;
char c;
};
struct b {
float f;
float g;
};
int main(void)
{
static struct b b;
return ((struct a *)&b)->i; /* { dg-warning "will break strict-aliasing" } */
}