User account creation filtered due to spam.

Bug 42876 - Missed aliasing warnings
Summary: Missed aliasing warnings
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-26 17:01 UTC by christophe.lyon
Modified: 2010-02-07 20:24 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Sample input code (409 bytes, text/plain)
2010-01-26 17:02 UTC, christophe.lyon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description christophe.lyon 2010-01-26 17:01:32 UTC
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.
Comment 1 christophe.lyon 2010-01-26 17:02:19 UTC
Created attachment 19714 [details]
Sample input code