This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/80622] New: wrong code at -O1 and above in both 32-bit and 64-bit modes on x86_64-linux-gnu
- From: "chengniansun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 03 May 2017 23:02:42 +0000
- Subject: [Bug c/80622] New: wrong code at -O1 and above in both 32-bit and 64-bit modes on x86_64-linux-gnu
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80622
Bug ID: 80622
Summary: wrong code at -O1 and above in both 32-bit and 64-bit
modes on x86_64-linux-gnu
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
Target Milestone: ---
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 8.0.0 20170503 (experimental) [trunk revision 247550] (GCC)
$ gcc-trunk small.c -O3 ; ./a.out
0
$ gcc-trunk small.c -O3 -m32 ; ./a.out
0
$ gcc-trunk small.c -O1 -m32 ; ./a.out
0
$ gcc-trunk small.c -O0 -m32 ; ./a.out
4
$
$ cat small.c
int printf(const char *, ...);
struct S2 {
int f2;
char f4;
int f5;
char f6;
} a;
int main() {
struct S2 b[][1] = {3, 0, 3, 4, 3, 0, 3, 4, 3, 0, 3, 4, 3, 0, 3, 4, 3,
0, 3, 4, 3, 0, 3, 4, 3, 0, 3, 4, 3, 0, 3, 4, 3, 0,
3, 4, 3, 4, 7, 7, 3, 5, 0, 3, 4, 7, 7, 3, 5, 0, 3,
4, 3, 4, 7, 7, 3, 5, 0, 3, 4, 7, 7, 3, 5, 0, 3, 4};
a = b[4][0];
b[4][0].f4 &printf("%d\n", a.f6);
return 0;
}
$
$ gcc-5.4 small.c -O3 -m32 ; ./a.out
4
$