[Issue 5570] 64 bit C ABI not followed for passing structs and complex numbers as function parameters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 26 07:13:49 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5570


Iain Buclaw <ibuclaw at ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw at ubuntu.com


--- Comment #26 from Iain Buclaw <ibuclaw at ubuntu.com> 2012-06-26 07:16:09 PDT ---
(In reply to comment #25)
> Sigh – seems like I was not exactly right about how GDC and LDC are handling
> arrays. Instead of treating them like the equivalent struct, they are treated
> as if length and pointer were two separate arguments, with the important
> difference of course being that with the x86_64 ABI, structs are never only
> partly passed in registers (i.e., if there is only one register left, they
> would still pass the length in it and only push the pointer on the stack).
> 

They are created as a two field struct in GDC.

eg, delegates (D arrays are a little above)
https://github.com/D-Programming-GDC/GDC/blob/master/gcc/d/d-glue.cc#L3801

which calls:
https://github.com/D-Programming-GDC/GDC/blob/master/gcc/d/d-codegen.cc#L1514


> The LDC x86_64 ABI implementation has had the following explanatory comment
> since it was originally written in 2009:
> 
> > This helps make things like printf("%.*s", o.toString()) work as expected; if we didn't do this that wouldn't work if there were 4 other integer/pointer arguments before the toString() call because the string got bumped to memory with one integer register still free.
> 

"%*.s" works purely out of coincidence.  You should not rely on it working at
all - and if you are, you should really instead be fixing your program.


Regards
Iain

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list