$ gcc -Wstrict-aliasing -fstrict-aliasing -c test.c 
test.c: In function ‘f1’:
test.c:2: warning: dereferencing type-punned pointer will break strict-aliasing
rules
$ cat test.c 
void f2(char **p);
void f1(unsigned char *bits) { f2((char **)&bits); };
$

but:

     the same address as an object of a different type, unless the
     types are almost the same.  For example, an `unsigned int' can
     alias an `int', but not a `void*' or a `double'.  A character type
     may alias any other type.

Signed/unsigned casts or casts to char should not produce a warning according
to the documentation.


-- 
           Summary: wrong warning with -Wstrict-aliasing/-fstrict-aliasing
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wavexx at users dot sf dot net
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29901

Reply via email to