public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27192]  New: call through function pointer goes to wrong address
@ 2006-04-18  5:32 regehr at cs dot utah dot edu
  2007-03-30 18:55 ` [Bug target/27192] " eweddington at cso dot atmel dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: regehr at cs dot utah dot edu @ 2006-04-18  5:32 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-12-29 21:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-18  5:32 [Bug c/27192] New: call through function pointer goes to wrong address regehr at cs dot utah dot edu
2007-03-30 18:55 ` [Bug target/27192] " eweddington at cso dot atmel dot com
2007-04-03 23:24 ` eweddington at cso dot atmel dot com
2007-04-03 23:25 ` eweddington at cso dot atmel dot com
2007-04-03 23:38 ` eweddington at cso dot atmel dot com
2007-04-09 20:17 ` eweddington at cso dot atmel dot com
2007-05-30 19:23 ` eweddington at cso dot atmel dot com
2008-01-20 20:18 ` wvangulik at xs4all dot nl
2009-12-24 20:01 ` hutchinsonandy at gcc dot gnu dot org
2009-12-29 21:25 ` eric dot weddington at atmel dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).