[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 09:30:41 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5570
--- Comment #27 from klickverbot <code at klickverbot.at> 2012-06-26 09:33:02 PDT ---
(In reply to comment #26)
> (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 […]
> They are created as a two field struct in GDC.
Oh well, apparently GDC handles dynamic arrays like structs in most cases, but
as size_t/void* pairs for variadic arguments, ABI-wise – I discovered this
behavior looking at the generated assembly while working on the LDC vararg ABI,
and didn't expect formal arguments to be treated differently. Maybe the
behavior should be unified?
> "%*.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.
It does _not_ work only out of coincidence with LDC, as the ABI it is using was
apparently explicitly designed by Frits to support this, judging from the
comment I quoted before. It's platform-dependent, yes, but guaranteed to work –
with GDC/LDC, that is, as this official ABI docs don't specify any details for
passing array arguments. I suppose this was done to support code which assumes
x86 behavior.
In any case, I can't see much value in having it like this, and would certainly
find just treating dynamic arrays as structs more natural. I just wanted to
highlight that this needs to be discussed and probably documented.
--
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