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
Fixed dmd 1.036 and 2.020
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!
Very much related to: http://d.puremagic.com/issues/show_bug.cgi?id=2648
http://www.dsource.org/projects/phobos/changeset/2132
*** Issue 2648 has been marked as a duplicate of this issue. ***