[Issue 20773] New: Excessive calls to postblit when passing structs over varargs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 26 15:10:55 UTC 2020


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

          Issue ID: 20773
           Summary: Excessive calls to postblit when passing structs over
                    varargs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

Sample program:

```
void testVariadic(T)(int nargs, ...)
{
    foreach(i; 0 .. nargs)
    {
        auto arg = va_arg!T(_argptr);
    }
}

struct Postblit
{
    static int count = 0;
    int value;
    // ??? nothrow needed on X86 and X86_64
    this(this) nothrow { count++; }
}

void test2()
{
    auto a0 = Postblit(0);
    auto a1 = Postblit(1);
    auto a2 = Postblit(2);
    testVariadic!Postblit(3, a0, a1, a2);
    printf("Postblit called %d times\n", Postblit.count);
}
```

This prints:
Postblit called 6 times

--


More information about the Digitalmars-d-bugs mailing list