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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Benjamin Kosnik from comment #0)
> From this thread:
> http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00271.html
> 
> Compiling with -c -g -O2 -Wall from r143978, I only get one warning, but
> should get two.
> 
> struct A 
> { 
>   int j;
>   int i; 
> };
> 
> void foo()
> {
>   char buf[sizeof(struct A)];
> 
>   // warns
>   ((struct A*)buf)->i = 1;
>  
>   // does not warn
>   struct A* p = (struct A*) buf;
>   p->i = 4;
> }
> 
> Gives:
> alias2.c: In function ‘void foo()’:
> alias2.c:12: warning: dereferencing type-punned pointer will break
> strict-aliasing rules

Trying again with newer trunk, and I don't even get the first warning! GCC is
completely silent with all of these: 

$ /usr/local/bin/gcc -c -g -O2 -Wall 39117.c
$ /usr/local/bin/gcc -c -g -O2 -Wstrict-aliasing=1 39117.c
$ /usr/local/bin/gcc -c -g -O2 -Wstrict-aliasing=2 39117.c
$ /usr/local/bin/gcc -c -g -O2 -Wstrict-aliasing=3 39117.c
$ /usr/local/bin/gcc -c -g -O1 -Wall 39117.c
$ /usr/local/bin/gcc -c -g -O0 -Wall 39117.c
$ /usr/local/bin/gcc -c -g -Og -Wall 39117.c
$ /usr/local/bin/gcc -c -g -Os -Wall 39117.c
$ /usr/local/bin/gcc -c -g -O3 -Wall 39117.c
$ /usr/local/bin/gcc -c -g -Ofast -Wall 39117.c
$

Reply via email to