[Issue 20772] New: va_arg doesn't work for structs with copy constructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 26 14:44:55 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20772

          Issue ID: 20772
           Summary: va_arg doesn't work for structs with copy constructors
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

This prints:
CopyConstructor = 64:0:2:

```
void testVariadic(T)(int nargs, ...)
{
    printf(T.stringof ~ " = ");
    foreach(i; 0 .. nargs)
    {
        auto arg = va_arg!T(_argptr);
        static if (__traits(compiles, arg.value))
            printf("%d", arg.value);
            //assert(arg.value == i);
        else
            assert(arg == T.init);
        printf(":");
    }
    printf("\n");
}

struct CopyConstructor
{
    int value;
    this(int v) { this.value = v; }
    this(ref typeof(this) other) { this.value = other.value; }
}

void test4()
{
    auto a0 = CopyConstructor(0);
    auto a1 = CopyConstructor(1);
    auto a2 = CopyConstructor(2);
    testVariadic!CopyConstructor(3, a0, a1, a2);
}
```

--


More information about the Digitalmars-d-bugs mailing list