gcc -v Using built-in specs. Target: x86_64-suse-linux Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp --enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic --host=x86_64-suse-linux Thread model: posix gcc version 4.1.0 (SUSE Linux) ------------ Compile the following with cc -O2, gets wrong code. If you use -fno-strict-aliasing or -fno-schedule-insns2 it works. cc -O1 works. cc -O1 -fstrict-aliaseing -fschedule-insns2 fails. I might have prioritized this critical except I found the ref to -fno-strict-aliasing in the 4.1.2rc1 thread...
/* -O2 compiles the fetch of lx_id->id_id before it stores ** external_lx_id into the stack: movzwl 6(%rsp), %eax // oops, too soon movl %edi, 4(%rsp) testw %ax, %ax // tests garbage */ typedef int LG_LXID; typedef int i4; typedef unsigned short u_i2; typedef struct _LG_ID { u_i2 foo; u_i2 id_id; } LG_ID; void LGend( LG_LXID external_lx_id, i4 flag) { LG_ID *lx_id = (LG_ID*)&external_lx_id; if (lx_id->id_id == 0 || (i4)lx_id->id_id > flag) printf("barfo"); } -- Summary: Wrong code from -O2 taking ptr=(struct *)&int_proc_parm on x86_64 Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: schendel at kbcomputer dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30724