stack alignment bug in gcc 2.95.2

stevenj@gil-galad.mit.edu stevenj@gil-galad.mit.edu
Tue Nov 30 23:39:00 GMT 1999


Jeffrey Law wrote:
>Alignment can only be preserved if the OS & dld arrange to provide main
>with an aligned stack.
>
>If it's mis-aligned  when main is called, there's little we're going
>to be able to do about the problem.

I've modified my test program slightly to check whether the stack is 
aligned in main() (see below).  It is.  Then, in the subroutine "blah", it
is misaligned.  So, it really seems like a bug in gcc's stack alignment.
Can you suggest anything else to try?

Cordially,
Steven G. Johnson

PS. I'm using glibc-2.0.7.

------------------- cut here for test program ---------------------
/* Compile with gcc -O align_bug.c -o align_bug */
/* Output on my machine is: bad alignment in blah */

struct yuck {
     int blechh;
};

int one(void)
{
     return 1;
}

struct yuck ick(void)
{
     struct yuck y;
     y.blechh = 3;
     return y;
}

void blah(int foo)
{
     double foobar;
     if ((((long) &foobar) & 0x7)) printf("bad alignment in blah\n");
}

int main(void)
{
     double okay1;
     struct yuck y;
     double okay2;
     if ((((long) &okay1) & 0x7)) printf("bad alignment in main\n");
     if ((((long) &okay2) & 0x7)) printf("bad alignment in main\n");
     y = ick();
     blah(one());
     return 0;
}



More information about the Gcc-bugs mailing list