Sample program:
```
import core.stdc.stdarg;
import core.stdc.stdio;
struct Foo
{
int fld;
//this(this) { }
~this() { } // Make it non-POD.
}
void variableFoo(int num, ...)
{
va_list va;
va_start(va, num);
foreach (i; 0 .. num)
{
auto arg = va_arg!Foo(va);
printf("fld = %d\n", arg.fld);
}
}
void main()
{
auto f1 = Foo(1);
auto f2 = Foo(2);
auto f3 = Foo(3);
variableFoo(3, f1, f2, f3);
}
```
There is no reason why internally these can't be passed by invisible reference.
va_arg!() will need to be fixed in order to support this.
Comment #1 by kinke — 2020-04-26T18:02:56Z
(In reply to Iain Buclaw from comment #0)
> There is no reason why internally these can't be passed by invisible
> reference.
Not so sure about that; normally, the compiler creates a temporary in the caller, passes it by hidden ref, and lets the callEE destruct the temporary.
In the vararg case, there's no formal parameter, and the callee doesn't destruct.
Comment #2 by ibuclaw — 2020-04-27T15:02:45Z
structs with postblits and copy-ctors need to have the same applied as well.
Comment #3 by robert.schadek — 2024-12-13T19:08:18Z