[Issue 20770] New: error: cannot pass types that need destruction as variadic arguments
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 26 14:26:20 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20770
Issue ID: 20770
Summary: error: cannot pass types that need destruction as
variadic arguments
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
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.
--
More information about the Digitalmars-d-bugs
mailing list