For the lulz: ddmd vs libdparse lexer timings

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 5 01:04:41 PST 2015


On 5 January 2015 at 08:28, Daniel Murphy via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> "David Nadlinger"  wrote in message
> news:qlzdmlnzlklofmlkqpby at forum.dlang.org...
>
>> It is. It breaks vararg cross-platform compatibility (e.g. Linux x86 vs.
>> Linux x86_64) and GDC/LDC will never need it. It's something that we really
>> to be fixed sooner than later. The only reason why the current situation is
>> bearable is that C varargs are rarely ever used in D-only code.
>
>
> Do you know how to fix it in dmd?  I don't know why it's there in the first
> place.

It is there because you still use a synthetic pointer for C varargs on
x86_64.  This synthetic pointer needs to be initialised to point to a
static array otherwise bad things happen when you pass on to C.  Enter
__va_argsave to the rescue.

void foo(int bar, ...)
{
  va_list* va = void;
  va_list[1] __va_argsave;
  va = &__va_argsave;

  ...
}

The above being compiler generated by DMD.


More information about the Digitalmars-d mailing list