This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/42876] New: Missed aliasing warnings


Hello,
With the attached sample program I would expect aliasing warnings from the
compiler (in function myfunc), which are not produced by GCC 4.4.3, as follows:

$ gcc -Wall -Wextra vbsl.c -o vbsl -O0
[no message]
$ ./vbsl
vec4:
vec[0]=0.000000
vec[1]=0.000000
vec4:
vec[0]=2.100000
vec[1]=2.200000

$ gcc -Wall -Wextra vbsl.c -o vbsl -O3
vbsl.c: In function 'myfunc':
vbsl.c:41: warning: 'result' is used uninitialized in this function
[actually, 'result' is written to, so this warning is incorrect]

$  ./vbsl
vec4:
vec[0]=0.000000
vec[1]=0.000000
vec4:
vec[0]=0.000000
vec[1]=0.000000

[the result is different from -O0, as the compiler optmized the code]

$ gcc -Wall -Wextra vbsl.c -o vbsl -O3 -Wstrict-aliasing
vbsl.c: In function 'myfunc':
vbsl.c:41: warning: 'result' is used uninitialized in this function
[same message as above, while there are aliasing issues, which should be
reported]

$ gcc -Wall -Wextra vbsl.c -o vbsl -O3 -fmudflap -lmudflap
[no message, ie mudflap cancels the 'unintialized' warning]
$ ./vbsl
vec4:
vec[0]=0.000000
vec[1]=0.000000
vec4:
vec[0]=2.100000
vec[1]=0.000000
[yet another different output, but no warning from mudflap]

But:

$ valgrind ./vbsl [using valgrind 3.5.0]
vec4:
vec[0]=0.000000
vec[1]=0.000000
vec4:
vec[0]=2.100000
==27973== Conditional jump or move depends on uninitialised value(s)
==27973==    at 0x30C754400C: __printf_fp (in /lib64/tls/libc-2.3.4.so)
==27973==    by 0x30C754191A: vfprintf (in /lib64/tls/libc-2.3.4.so)
==27973==    by 0x4A2005E: __mfwrap_printf (in xxx/lib64/libmudflap.so.0.0.0)
==27973==    by 0x4011DB: main (in /home/lyon/tmp/bug-gcc/vbsl)


The interactions between all these variants are a bit confusing.


-- 
           Summary: Missed aliasing warnings
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christophe dot lyon at st dot com
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]