[Bug c/70143] [6 Regression] false strict-aliasing warning

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 9 10:41:00 GMT 2016


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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to rguenther@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.


More information about the Gcc-bugs mailing list