Bus error interfacing with C function returning large struct

Jacob Carlborg doob at me.com
Wed Apr 17 05:19:25 PDT 2013


On 2013-04-17 13:43, John Colvin wrote:

> clang just happened to put the arguments to foo in to registers
> different on 10.6.3
> Instead of loading the 0 argument in to eax it loaded the pointer to the
> struct like it would in system V ABI (linux)
>
> I have no idea whether this is a complete coincidence, or whether clang
> has changed it's approach to the OS X abi, or whether the ABI itself has
> changed.

Ok, I see. The docs for the ABI says:

The called function returns structures according to their aligned size.

* Structures 1 or 2 bytes in size are placed in EAX.
* Structures 4 or 8 bytes in size are placed in: EAX and EDX.
* Structures of other sizes are placed at the address supplied by the 
caller. For example, the C++ language occasionally forces the compiler 
to return a value in memory when it would normally be returned in 
registers. See “Passing Arguments” for more information.



-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list