digitalmars.D.bugs - [Issue 20773] New: Excessive calls to postblit when passing structs
- d-bugmail puremagic.com (42/42) Apr 26 2020 https://issues.dlang.org/show_bug.cgi?id=20773
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 puremagic.com Reporter: ibuclaw 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 --
Apr 26 2020