[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] avr-gcc 3.4.3 confused about function pointers
From: |
John Regehr |
Subject: |
Re: [avr-gcc-list] avr-gcc 3.4.3 confused about function pointers |
Date: |
Mon, 17 Apr 2006 20:55:48 -0600 |
User-agent: |
Thunderbird 1.5 (X11/20060111) |
> Sorry, I can't follow the somewhat tangled logic of that code, so I
> can't see whether GCC 4.1.0 still produces buggy code for it or not.
You weren't supposed to follow the logic, it was an automatically
extracted subset of a machine generated file.
A shorter program that gcc 4.1.0 miscompiles is below. Compile with -Os
and the problem should be obvious: the program icalls to the byte
address of bar() rather than the double-byte address.
John Regehr
struct fseqp_void
{
void (*p) (void);
void (*e) (void);
};
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 = bar + 1;
c[0].p = bar;
foo ();
struct fseqp_void x = c[0];
void (*start) (void) = x.p;
((*start)) ();
return 0;
}