the following test compiled with dmd 1.034 on linux should return via a hidden pointer parameter, but is actually returned in registers:
struct S
{
int x;
int z;
static S foo()
{
S s = {1,2};
return s;
}
}
becomes
_D4test1S3fooFZS4test1S:
push EBP
mov EBP,ESP
sub ESP,8
mov dword ptr -8[EBP],1
mov dword ptr -4[EBP],2
mov EDX,-4[EBP]
mov EAX,-8[EBP]
leave
ret
Comment #1 by bugzilla — 2008-10-20T22:20:25Z
Fixed dmd 1.036 and 2.020
Comment #2 by tomas — 2009-05-12T12:30:04Z
the spec now says:
# For Windows, 1, 2 and 4 byte structs are returned in EAX.
# For Windows, 8 byte structs are returned in EDX,EAX, where EDX gets the most significant half.
# For other struct sizes, the return value is stored through a hidden pointer passed as an argument to the function.
I don't think just removing the info on linux is a satisfactory fix, the asm is still the same!