From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E36753858C62; Mon, 12 Feb 2024 16:08:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E36753858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707754110; bh=YYNcYJf2PCTMrlfWNtxFENXnCBoQZaORAU3anXVru18=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G1g76uIvklJYbYhDMSKEtOLIDQxrtgHtSqUxzvpW3rl8hxX6mGJ40iO/j22kLOqpn MQsBHL/N0HqRZlqX2zJCR6k1JzUbpQSnvq8s8oBbex6ZJA0NqjcANBCbwi/q0YBFgB KQK96V6vYXd2yH3yP9UD5n6itM6D5xlyGfzYh6VI= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/113758] d: Callee destructor call invalidates the live object, not the temporary Date: Mon, 12 Feb 2024 16:08:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113758 --- Comment #1 from GCC Commits --- The master branch has been updated by Iain Buclaw : https://gcc.gnu.org/g:3c57b1c12a8e34d50bdf6aaf44146760db6d1b33 commit r14-8933-g3c57b1c12a8e34d50bdf6aaf44146760db6d1b33 Author: Iain Buclaw 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.=