https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100470
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Keywords| |wrong-code Last reconfirmed| |2022-09-20 --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- 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 = decltype(sizeof(0)); void* operator new(size_t, void* p) noexcept { return p; } namespace std { template<typename T> T&& declval() noexcept; template<typename T> constexpr bool is_nothrow_move_constructible_v = noexcept(new (declval<void*>()) T(declval<T>())); } struct S1{ S1(S1&&) noexcept(false); }; struct S2{ S2(S2&&) noexcept(false) = default; }; struct S3{ S3(S3&&) noexcept(false){} }; struct S4{ S4(S4&&) = default; }; static_assert(!std::is_nothrow_move_constructible_v<S1>); // OK static_assert(!std::is_nothrow_move_constructible_v<S2>); // OK static_assert(!std::is_nothrow_move_constructible_v<S3>); // OK static_assert( std::is_nothrow_move_constructible_v<S4>); // 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.