From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DEF3B3858C2F; Tue, 20 Sep 2022 09:43:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEF3B3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663667006; bh=BrFQKSlZhsvMwHE32+xRSgTE3d5zp24j72D6GwTNNts=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xiGQD6pAZvroEnpyjvEQ3s7Ji4M6E21FCPmqowU+j4DcuCSiLkK4vqaq/LuPG/j/o Ase5zf8pqO+UDE3qdvhXpxWJk6mu6NcxZN6ZAJ+s2Yg9LuTlPmX84LLNi6sNPDQSsy xrK1awKRKYJzMicvWwgXGxzrO9jQNlS48ZICf1LQ= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100470] std::is_nothrow_move_constructible incorrect behavior for explicitly defaulted members Date: Tue, 20 Sep 2022 09:43: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: 11.1.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: everconfirmed bug_status keywords 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=3D100470 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Keywords| |wrong-code Last reconfirmed| |2022-09-20 --- Comment #3 from Jonathan Wakely --- https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1286r2.html says = that S" has a potentially-throwing move constructor. It looks like the __is_nothrow_constructible built-in gets this wrong: using size_t =3D decltype(sizeof(0)); void* operator new(size_t, void* p) noexcept { return p; } namespace std { template T&& declval() noexcept; template constexpr bool is_nothrow_move_constructible_v =3D noexcept(new (declval()) T(declval())); } struct S1{ S1(S1&&) noexcept(false); }; struct S2{ S2(S2&&) noexcept(false) =3D default; }; struct S3{ S3(S3&&) noexcept(false){} }; struct S4{ S4(S4&&) =3D default; }; static_assert(!std::is_nothrow_move_constructible_v); // OK static_assert(!std::is_nothrow_move_constructible_v); // OK static_assert(!std::is_nothrow_move_constructible_v); // OK static_assert( std::is_nothrow_move_constructible_v); // OK static_assert(!__is_nothrow_constructible(S1, S1)); // OK static_assert(!__is_nothrow_constructible(S2, S2)); // failed static_assert(!__is_nothrow_constructible(S3, S3)); // OK static_assert( __is_nothrow_constructible(S4, S4)); // OK This makes it a libstdc++ regression in GCC 11.1 and later, because we use __is_nothrow_construcitble now, instead of a pure library implementation for the traits.=