From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4DEFE3858414; Sun, 3 Mar 2024 00:01:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DEFE3858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709424074; bh=KHLz97j/vZKQgTwBgKGQbREh9Bt/XvlDhg3SS0q4dps=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Tnl+Tl9G8t97wI1TuWBWg3cBFQVGGhf+p9qz1go7H5Oc461pUNVlC8E41oGrmUXyq d17+FqTlb0bygo0ui7D7YqsU2YZB499qVfn7CWWZXaGQUn/5ZqDxsL/X+m8Jt5eptT d3AstLxuQaMqEJkaNQUYNVPTVkZedxr9kbbbL5C4= 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: Sun, 03 Mar 2024 00:00:56 +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 #2 from GCC Commits --- The releases/gcc-13 branch has been updated by Iain Buclaw : https://gcc.gnu.org/g:e64fbf38e0b408696a97fbceb131ed1d19cbcd03 commit r13-8399-ge64fbf38e0b408696a97fbceb131ed1d19cbcd03 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. (cherry picked from commit 3c57b1c12a8e34d50bdf6aaf44146760db6d1b33)=