Possible bug in PowerPC structure passing
Stan Shebs
shebs@apple.com
Tue Apr 4 14:59:00 GMT 2000
Apple is switching from using EGCS 1.1.2 to GCC 2.95.2 for building
MacOS X, and has encountered a number of regressions. One of them
is that passing medium-sized structures by value doesn't work,
because memcpy's result steps on the save area (which then causes
OS X networking stack to fall over). I've included a small test
case below. I'm not 100% certain this is a GCC bug, because we
have a lot of local mods and no AIX systems to test with; however,
if I'm on a PowerPC Linux system and compile the test case with
gcc -mcall-aix -O -c dek.c
gcc dek.o
then 1.1.2 (the default on my Linux system) wins, while 2.95.2 and
yesterday's checkout both lose. You need -mcall-aix to emulate the
MacOS calling convention, -mcall-sysv doesn't seem to have a problem.
So if some kind person could try this out on a real AIX system and
report back, I'd be very grateful.
Turly O'Connor <turly@apple.com> has worked up a skanky hack
to calls.c that gets our networking people going again, but it's
pretty ugly, so I won't pollute this list unless asked. :-)
Stan
dek.c:
typedef struct {
char y;
char x[32];
} X;
int z (void)
{
X xxx;
xxx.x[0] =
xxx.x[31] = '0';
xxx.y = 0xf;
return f (xxx, xxx);
}
int main (void)
{
extern int printf (const char *, ...);
int val;
val = z ();
printf ("f(xxx) returns '%c' (==0x%x) [should be 0x60]\n", val, val);
return 0;
}
int f(X x, X y)
{
if (x.y != y.y)
return 'F';
return x.x[0] + y.x[0];
}
More information about the Gcc
mailing list