Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 190154

Summary: gcc 4.2.0 miscompiles bitfields
Product: Gentoo Linux Reporter: Reimar Döffinger <Reimar.Doeffinger>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: major CC: loki_val
Priority: High    
Version: 2007.0   
Hardware: All   
OS: Linux   
URL: http://lists.mplayerhq.hu/pipermail/mplayer-cvslog/2007-August/030927.html
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: testcase that miscompiles for me

Description Reimar Döffinger 2007-08-25 08:27:03 UTC
Copied from URL:
For anything bigger than -O1 it gives this output:
> reimar at hokum ~ $ gcc -O2 bitbug.c -o bitbug
> reimar at hokum ~ $ ./bitbug 0 1
> vals: 0 0 1 0

output should be
> vals: 0 -1 1 0

If you can confirm that this is not only due to some breakage on my system, I think gcc 4.2.0 should be -amd64, since this is a quite trivial feature and it is completely broken.
I will attach the sample C file shortly.
Comment 1 Reimar Döffinger 2007-08-25 08:27:58 UTC
Created attachment 129116 [details]
testcase that miscompiles for me
Comment 2 Peter Alfredsen (RETIRED) gentoo-dev 2007-08-25 09:15:06 UTC
pa@loki ~ $ for optlevel in 0 1 2 s 3; do gcc -O${optlevel} bitbug.c -o bitbug&&./bitbug 0 1&&rm ./bitbug; done
vals: 0 -1 1 0
vals: 0 1 1 0
vals: 0 0 1 0
vals: 0 0 1 0
vals: 0 0 1 0

This is on i686-pc-linux-gnu gcc 4.2.0
Comment 3 SpanKY gentoo-dev 2007-08-25 09:16:11 UTC
this is already known and fixed in gcc-4.2.1
Comment 4 SpanKY gentoo-dev 2007-10-07 02:14:51 UTC
gcc-4.2.1 in the tree