From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 55326385B83C; Wed, 28 Sep 2022 12:00:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55326385B83C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664366425; bh=boEspw8uykKYzBvsgWanVptjGkkveQCYDFKmyAWUbJw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=U2P9skMyEbSz4hOMVZ5Qb85N4W9JEYUE1rIjbik01V+mZ22TZyFUrCflJr+SrC9ck apg8gBo8lmWwaLIxZu6v31j4glJDytS3wCxeQd1+gJzVfUNfHMX0i7G2SFFsgKEx9Y 8cxT3Cjs/1KVW2zrf7txOy0rFGxnXMFbEz/4EpJ4= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107065] GCC treats rvalue as an lvalue Date: Wed, 28 Sep 2022 12:00:25 +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: 12.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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: keywords bug_status everconfirmed cf_reconfirmed_on 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=3D107065 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-09-28 --- Comment #1 from Jonathan Wakely --- Reduced to remove the library dependency: enum Cat { prvalue, lvalue, xvalue }; template struct value_category { // Or can be an integral or enum value static constexpr auto value =3D prvalue; }; template struct value_category { static constexpr auto value =3D lvalue; }; template struct value_category { static constexpr auto value =3D xvalue; }; // Double parens for ensuring we inspect an expression, // not an entity #define VALUE_CATEGORY(expr) value_category::value constexpr bool global =3D true; static_assert( VALUE_CATEGORY(!(!global)) =3D=3D prvalue, "GCC gets this ri= ght" ); int main() { bool b =3D true; if ( VALUE_CATEGORY(!(!b)) !=3D prvalue ) throw 1; }=