[Issue 18029] extra dtor call with typed variadic argument (or missing postblit)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 20 14:28:22 UTC 2024


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

ilya.yanok at gmail.com changed:

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

--- Comment #1 from ilya.yanok at 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.

--


More information about the Digitalmars-d-bugs mailing list