From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6306 invoked by alias); 18 Apr 2006 05:32:27 -0000 Received: (qmail 6290 invoked by uid 48); 18 Apr 2006 05:32:23 -0000 Date: Tue, 18 Apr 2006 05:32:00 -0000 Subject: [Bug c/27192] New: call through function pointer goes to wrong address X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "regehr at cs dot utah dot edu" 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 X-SW-Source: 2006-04/txt/msg01393.txt.bz2 List-Id: The program below confuses gcc in such a way that it generates code loading the byte-address of bar() into the Z register, which causes icall to jump off to neverneverland. Rather, the double-byte address of bar() should be loaded into Z before the indirect call. This bug is also present in gcc 4.0.3 and 3.4.3. avr-gcc -v gives: Target: avr Configured with: ../gcc-4.1.0/configure --prefix=/home/regehr/gcc-4.1.0-avr-bin --disable-libssp --disable-nls --target=avr Thread model: single gcc version 4.1.0 Compile with: avr-gcc -Os -Wall shifty.c -o shifty.elf Program: struct fseqp_void { void (*p) (void); char *e; }; struct fseqp_void c[2]; void bar (void) { } void foo (void) { int i; for (i=0; i<32; i++); } int main (void) { c[0].e = (char *)bar + 2; c[0].p = bar; foo (); struct fseqp_void x = c[0]; void (*start) (void) = x.p; (*start)(); return 0; } -- Summary: call through function pointer goes to wrong address Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: regehr at cs dot utah dot edu GCC host triplet: i686-linux-gnu GCC target triplet: avr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27192