From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2B9B83858D20; Mon, 11 Mar 2024 15:12:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B9B83858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710169925; bh=ICUoMXpigbb57YVRHvad8YBZOYveuC82mjC5+NFVz/Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wfapxv2pPT2RWCrpcDQBXzKNun96rn95+1m45lAguNZPvKlxSfI2Tx7rHP8hzZfNf 48NrN/K/ZYqf329FH8pVOFq4o+B3tFknn548WzVZasoY71HLYNkAv6F2eHmmV9UeIC 7ADRU+vsw4Z0TMN94eKERQF8k2tZVdFbBLwD1n+0= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111284] [11/12/13/14 Regression] Some passing-by-value parameters are mishandled since GCC 9, affecting libstdc++'s constexpr std::string Date: Mon, 11 Mar 2024 15:12:04 +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: 13.2.0 X-Bugzilla-Keywords: accepts-invalid, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 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=3D111284 --- Comment #9 from Patrick Palka --- (In reply to Jakub Jelinek from comment #8) > Created attachment 57648 [details] > gcc14-pr111284.patch >=20 > So, I've tried to fix this by constexpr evaluating the arguments passed to > PARM_DECLs with TREE_ADDRESSABLE types in the caller as lvalues rather th= an > rvaluea and later, if we try to evaluate the PARM_DECL in the callee as l= val, > lookup the value and use that, if it is rval constexpr evaluate again as > rvalue. > There is a complication for qualified type, say if the argument is const = in > the callee and caller is passing reference to non-const, adjust_temp_type > can't handle that when it isn't a rvalue. Interesting, hopefully this fixes the std::string testcases in PR111258 and related PRs? And perhaps the following augmented testcase from this PR with a constexpr = dtor that checks valid(): void non_constant(); struct self_locator { self_locator() =3D default; constexpr self_locator(const self_locator&) noexcept : this_{this} {} constexpr self_locator& operator=3D(const self_locator&) noexcept { ret= urn *this; } constexpr bool valid() const noexcept { return this_ =3D=3D this; } constexpr ~self_locator() { if (!valid()) non_constant(); } self_locator *this_ =3D this; }; constexpr bool demonstrator(self_locator x) noexcept { return x.valid(); } static_assert(demonstrator(self_locator{}), ""); static_assert([](self_locator x){ return x.valid(); }(self_locator{}), "");=