Thread overview
[Issue 21036] wrong code for non-pod types when compiled function with variadic static array
Jul 16, 2020
Stefan Koch
Aug 24, 2020
Stefan Koch
Jul 13, 2021
kinke
July 14, 2020
https://issues.dlang.org/show_bug.cgi?id=21036

Илья Ярошенко <ilyayaroshenko@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--
July 16, 2020
https://issues.dlang.org/show_bug.cgi?id=21036

Stefan Koch <uplink.coder@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uplink.coder@gmail.com

--- Comment #1 from Stefan Koch <uplink.coder@gmail.com> ---
It looks like the dtor is called on compiler created temporaries as well as on the actual arguments.

--
August 24, 2020
https://issues.dlang.org/show_bug.cgi?id=21036

--- Comment #2 from Stefan Koch <uplink.coder@gmail.com> ---
I assume the fix for this is to not call the dtors on compiler created temporaries. Let's see where that leads.

--
July 13, 2021
https://issues.dlang.org/show_bug.cgi?id=21036

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #3 from kinke <kinke@gmx.net> ---
It works as expected with an explicit array literal, i.e.:

void main()
{
    bar([S.init, S.init]);
}

In that case, the AST contains an ArrayLiteralExp with 2 StructLiteralExp elements.

In the problematic case, the generated ArrayLiteralExp contains 2 temporaries - apparently for destruction, but the 2 elements are both rvalues and are supposed to be moved, so no destruction/temporaries necessary.

--