_argptr woes

Lars Ivar Igesund larsivar at igesund.net
Sat Mar 17 05:36:36 PDT 2007


Frits van Bommel wrote:

> Lars Ivar Igesund wrote:
>> Frits van Bommel wrote:
>> 
>>> [2]: At least, I presume this discussion was brought on by the
>>> non-portable code in tango.text.convert.Layout?
>> 
>> Rather that that code breaks because GDC don't follow the D ABI :)
> 
> You may notice that the same text that specifies _argptr should be a
> void* then goes on to say[1] "To protect against the vagaries of stack
> layouts on different CPU architectures, use std.stdarg to access the
> variadic arguments".
> Doesn't this pretty much mean there's no good reason for _argptr to be a
> void* instead of a CPU-specific va_list type as declared by std.stdarg,
> which would be aliased to whatever the appropriate type for the CPU
> architecture is. (i.e. gcc.builtins.__builtin_va_list for GDC, void* for
> DMD)
> 
> In short: I don't think GDC is broken here, the ABI is just still a bit
> x86-centric and is the one that should be fixed. There is simply no good
> reason to decide in the standard that _argptr must be a pointer. It may
> be simpler (compiler) implementation-wise, but if you can't portably use
> the pointer anyway you may as well leave _argptr's type up to the
> compiler and just specify it as std.vararg.va_list, whatever that may be.

If there is an actual win in having _argptr as a pointer as opposed to the
current behaviour, for instance the possibility to easily indexing into the
argument list, then there is a good reason to have it in the specification.

It is possible that other ways to have this working can be devised, but not
being able to index into them portably, when they in any case need to be in
the correct order, seems to me to be silly.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango



More information about the Digitalmars-d mailing list