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

--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 9 Mar 2016, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70143
> 
> --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> (In reply to rguent...@suse.de from comment #5)
> > Though that will FAIL the gcc.dg/Wstrict-aliasing-struct-member.c
> > I added.
> > 
> > Note that we then also don't warn for
> > 
> > struct a {
> >   int i;
> >   int k;
> > };
> > struct b {
> >   struct a a;
> >   int j;
> > };
> > int main(void) {
> >   static struct b b;
> >   struct a *ap=(struct a *)&b;
> >   return ((struct b *)&ap->k)->j;
> > }
> > 
> > then either.  Doing this kind of warnings strictly based on alias
> > sets only is going to be "broken" - though I consider our strict-aliasing
> > warnings broken anyway (and I don't think we can ever implement something
> > sensible :/).
> 
> The point of -Wstrict-aliasing=3 is to give very few false positives and still
> catch lots of likely bugs.  So, if there is INDIRECT_REF or *MEM_REF involved
> and you can't analyze what it points to, we should err on the side that it
> might be valid, people can still use -Wstrict-aliasing=2 that will warn even
> about these.

Ok, I'll remove the new test and test

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c     (revision 234025)
+++ gcc/c-family/c-common.c     (working copy)
@@ -1568,7 +1568,9 @@ strict_aliasing_warning (tree otype, tre
           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");

then.

Reply via email to