From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 385E0385E038; Tue, 14 Apr 2020 15:23:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 385E0385E038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586877815; bh=if7a2uyh61xZ6FHStYO/1KF5aVPAARruoDmpwep9esw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=FblkFsek1FrPFmGVm41OC7odbxNHh4PzjYjoP9vE82AY8DjeEoiYEnUFR73aD+4Nm F1Uu6ClKkn6EaY0SRRqAsXWy399tQ7Mh6E1OzWWAcQ9jIOkNvizAT39Vp6n93jK5G8 8vfXcySiz0VN1Uf5JORoa1feqpDqeABQYAbxiVFQ= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94034] [10 Regression] Broken diagnostic: 'result_decl' not supported by dump_expr Date: Tue, 14 Apr 2020 15:23:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.0 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2020 15:23:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94034 --- Comment #8 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:b256222910cfa4a9b2b477dff8954e51fdc36bb9 commit r10-7718-gb256222910cfa4a9b2b477dff8954e51fdc36bb9 Author: Patrick Palka Date: Wed Apr 8 13:14:42 2020 -0400 c++: Stray RESULT_DECLs in result of constexpr call [PR94034] When evaluating the initializer of 'a' in the following example struct A { A() =3D default; A(const A&); A *p =3D this; }; constexpr A foo() { return {}; } constexpr A a =3D foo(); the PLACEHOLDER_EXPR for 'this' in the aggregate initializer returned by foo gets resolved to the RESULT_DECL of foo. But due to guaranteed RVO, the 'this' should really be resolved to '&a'. Fixing this properly by immediately resolving 'this' and PLACEHOLDER_EX= PRs to the ultimate object under construction would in general mean that we wo= uld no longer be able to cache constexpr calls for which RVO possibly applies, because the result of the call may now depend on the ultimate object under construction. So as a mostly correct stopgap solution that retains cachability of RVO= 'd constexpr calls, this patch fixes this issue by rewriting all occurrenc= es of the RESULT_DECL in the result of a constexpr function call with the current object under construction, after the call returns. This means the 'this' poin= ter during construction of the temporary will still point to the temporary object instead of the ultimate object, but besides that this approach seems functionally equivalent to the proper approach. gcc/cp/ChangeLog: PR c++/94034 * constexpr.c (replace_result_decl_data): New struct. (replace_result_decl_data_r): New function. (replace_result_decl): New function. (cxx_eval_call_expression): Use it. * tree.c (build_aggr_init_expr): Set the location of the AGGR_INIT_EXPR to that of its initializer. gcc/testsuite/ChangeLog: PR c++/94034 * g++.dg/cpp0x/constexpr-empty15.C: New test. * g++.dg/cpp1y/constexpr-nsdmi6a.C: New test. * g++.dg/cpp1y/constexpr-nsdmi6b.C: New test. * g++.dg/cpp1y/constexpr-nsdmi7a.C: New test. * g++.dg/cpp1y/constexpr-nsdmi7b.C: New test.=