From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 16ACE3858D37; Thu, 27 Apr 2023 17:39:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16ACE3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682617199; bh=qsh3AqldyoDDFtSqVBIXoofkjly4NVSniUz4xWrW3JY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DZ5Tn1vFgVbKGG3qXrUVjo/XwuLxG3gfNqAeSrZT49C3MN7hgQgIMww+1KT/s2yVA U4bgAL0nQa3UFYhthPipHOfrIC03MiPnPo5fXwYBwwIUOfpbDHF0W1kylDWfPc1YT/ LURGSD8eYzElW85qw0rFb4Opm8CFfd6c8cKCKq2I= From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108759] "mandatory copy elision" not implemented during constant evaluation redux Date: Thu, 27 Apr 2023 17:39:58 +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.0 X-Bugzilla-Keywords: rejects-valid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: arthur.j.odwyer at gmail dot com 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: cc 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=3D108759 Arthur O'Dwyer changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.j.odwyer at gmail d= ot com --- Comment #2 from Arthur O'Dwyer --- I believe what I'm going to say is simply a duplicate of Davis's report, but just in case it's different, I'll add mine here. This is a slightly modified version of the example from [class.copy.elision], merely modified so that g= () returns a C++17 prvalue instead of relying on NRVO/copy-elision. Original example: https://eel.is/c++draft/class.copy.elision#2 Modified example: // https://godbolt.org/z/n43jPs1Kj struct A { void *p; constexpr A(): p(this) {} }; constexpr A g() { return A(); } constexpr A b =3D g(); // well-formed, b.p points to b static_assert(b.p =3D=3D &b); MSVC and Clang accept. GCC incorrectly rejects: :11:19: error: 'A{((void*)(&))}' is not a constant expression 11 | constexpr A b =3D g(); // well-formed, b.p points to b | ^ :12:19: error: non-constant condition for static assertion 12 | static_assert(b.p =3D=3D &b); | ~~~~^~~~~=