From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2336 invoked by alias); 25 Sep 2003 15:52:21 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2328 invoked by uid 48); 25 Sep 2003 15:52:20 -0000 Date: Thu, 25 Sep 2003 16:56:00 -0000 From: "yamt at mwd dot biglobe dot ne dot jp" To: gcc-bugs@gcc.gnu.org Message-ID: <20030925155217.12404.yamt@mwd.biglobe.ne.jp> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug optimization/12404] New: pointer to union member problem X-Bugzilla-Reason: CC X-SW-Source: 2003-09/txt/msg01919.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12404 Summary: pointer to union member problem Product: gcc Version: 3.3.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yamt at mwd dot biglobe dot ne dot jp CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386-unknown-netbsdelf1.6W GCC host triplet: i386--netbsdelf GCC target triplet: i386--netbsdelf compiling the following program with -O2 for i386 yields the latter asm output. % gcc -v Using built-in specs. Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc/configure --enable-long-long --disable-multilib --enable-threads --build=i386-unknown-netbsdelf --host=i386--netbsdelf --target=i386--netbsdelf : (reconfigured) /usr/src/tools/gcc/../../gnu/dist/gcc/configure --enable-long-long --disable-multilib --enable-threads --build=i386-unknown-netbsdelf1.6W --host=i386--netbsdelf --target=i386--netbsdelf Thread model: posix gcc version 3.3.1 ============================================================ #include int main() { union { int i; short s; } u[] = {{1}, {2}, {3}}; printf("%d\n", *&u->s); } ============================================================ .file "a.c" .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "%d\n" .text .p2align 2,,3 .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $24, %esp andl $-16, %esp subl $8, %esp movswl -24(%ebp),%eax # <= used before initialized. pushl %eax pushl $.LC0 movl $1, -24(%ebp) # <= initialize here movl $2, -20(%ebp) movl $3, -16(%ebp) call printf leave ret .size main, .-main .ident "GCC: (GNU) 3.3.1"