https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611
--- Comment #5 from Nikolas Klauser <nikolasklauser at berlin dot de> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Nikolas Klauser from comment #2)
> > static_assert(!noexcept(std::declval<const CopyConstructible&>())));
> >
> > is fine.
>
> It doesn't look fine to me! Is there a 'CopyConstructible(' missing?
>
> The reproducer for comment 3 would be helpful.
Oops! Yes, there is a CopyConstructible() missing around the declval.
Here is the reproducer for comment #3 (Godbolt:
https://godbolt.org/z/fYEzME3b8):
#include <type_traits>
#include <utility>
struct S {
S() noexcept(false) = default;
S(const S&) noexcept(false) = default;
S(S&&) noexcept(false) = default;
S& operator=(const S&) noexcept(false) = default;
S& operator=(S&&) noexcept(false) = default;
};
static_assert(!std::is_nothrow_default_constructible_v<S>);
static_assert(!std::is_nothrow_copy_constructible_v<S>);
static_assert(!std::is_nothrow_move_constructible_v<S>);
static_assert(!std::is_nothrow_copy_assignable_v<S>);
static_assert(!std::is_nothrow_move_assignable_v<S>);
static_assert(!noexcept(S()));
static_assert(!noexcept(S(std::declval<const S&>())));
static_assert(!noexcept(S(std::declval<S&&>())));
static_assert(!noexcept(std::declval<S&>() = std::declval<const S&>()));
static_assert(!noexcept(std::declval<S&>() = std::declval<S&&>()));
I think the relevant part in the standard is
https://eel.is/c++draft/except.spec, which states that anything marked
noexcept(false) is potentially throwing.