From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 53D0B3858428; Mon, 4 Sep 2023 11:16:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53D0B3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693826204; bh=dQ1R+pXBTxhRJeHJ8ecZZ0RmX9gPZzOViUZuLRp1gRM=; h=From:To:Subject:Date:From; b=LAJjKo6si+Mf5+Lztn88sBVQm3n8B5fwpNPvtu2vos3gnByHCujLwQmQL4zR+8Qjn 8iuWbCjSb5/TJUIKaJ8dDIT5TCVTEHHu1OQWMt1fpWbSMi/4R+JAYk8U6R9GpJX7vl 6MqfkaE2ZVTDdmKyMZpQ83m0ym+FG6Fyq/dWbTdk= From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111284] New: Some passing-by-value parameters are miscompiled since GCC 9 Date: Mon, 04 Sep 2023 11:16:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: de34 at live dot cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 111284 Summary: Some passing-by-value parameters are miscompiled since GCC 9 Product: gcc Version: 13.2.0 Status: UNCONFIRMED Keywords: accepts-invalid, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- GCC incorrectly rejects the following program since GCC 9 (https://godbolt.org/z/cGK1a1dqK): ``` class self_locator { public: 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; } private: 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{}), ""); ``` The `valid` member function should always return true. But if `self_locator= ` is passed by value, GCC can sometimes render the parameter in an inconsistent state (perhaps due to incorrect bitwise copy).=