_argptr woes

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat Mar 17 04:33:34 PDT 2007


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.


[1]: At the end of the section, after an example using manual pointer 
casting that seems to carefully avoid parameter types smaller than 
int.sizeof...



More information about the Digitalmars-d mailing list