--- Comment #27 from klickverbot <> 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:
------- You are receiving this mail because: -------

Reply via email to