https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113758

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Iain Buclaw
<ibuc...@gcc.gnu.org>:

https://gcc.gnu.org/g:e64fbf38e0b408696a97fbceb131ed1d19cbcd03

commit r13-8399-ge64fbf38e0b408696a97fbceb131ed1d19cbcd03
Author: Iain Buclaw <ibuc...@gdcproject.org>
Date:   Sun Feb 4 22:04:14 2024 +0100

    d: Fix callee destructor call invalidates the live object [PR113758]

    When generating the argument, check the isCalleeDestroyingArgs hook, and
    force a TARGET_EXPR to be created if true, so that a reference to the
    live object isn't passed directly to the function that runs dtors.

    When instead dealing with caller running destructors, two temporaries
    were being generated, one explicit temporary generated by the D
    front-end, and another implicitly by the code generator.  This has been
    reduced to one by setting DECL_VALUE_EXPR on the explicit temporary to
    bind it to the implicit slot created for the TARGET_EXPR, as that has
    the shorter lifetime of the two.

            PR d/113758

    gcc/d/ChangeLog:

            * d-codegen.cc (d_build_call): Force a TARGET_EXPR when callee
            destorys its arguments.
            * decl.cc (DeclVisitor::visit (VarDeclaration *)): Set
            SET_DECL_VALUE_EXPR on the temporary variable to make it a
placeholder
            for the TARGET_EXPR_SLOT.

    gcc/testsuite/ChangeLog:

            * gdc.dg/torture/pr113758.d: New test.

    (cherry picked from commit 3c57b1c12a8e34d50bdf6aaf44146760db6d1b33)

Reply via email to