Thread overview
[Issue 18029] extra dtor call with typed variadic argument (or missing postblit)
Dec 04, 2017
Ketmar Dark
Dec 17, 2022
Iain Buclaw
December 04, 2017
https://issues.dlang.org/show_bug.cgi?id=18029

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=18029

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
4 days ago
https://issues.dlang.org/show_bug.cgi?id=18029

ilya.yanok@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ilya.yanok@gmail.com

--- Comment #1 from ilya.yanok@gmail.com ---
The arguments are most definitely copied, one can easily see that by taking the
addresses of `vals[0]` and `a0` respectively. The spec is also pretty clear
that the contents of the array is invalid after the function exits, see 5.
here:
https://docarchives.dlang.io/v2.076.0/spec/function.html#typesafe_variadic_functions

So, that a0 remains unchanged is not really a mystery.

It is weird though, that neither copy constructor nor postblit is called (I tried adding a copy constructor), probably some kind of optimization? But should we require typed varargs to always be const then?

Then, the default opAssign calls the destructor on the lvalue being assigned. That seems to be correct, but since the value was never constructed, this causes a disparity in constructor/destructor calls you observe.

--