public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-100470-4-xer3VP94DN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100470-4@http.gcc.gnu.org/bugzilla/> 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.
next prev parent reply other threads:[~2022-09-20 9:43 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-07 11:16 [Bug libstdc++/100470] New: " oleksandr.koval.dev at gmail dot com 2021-09-06 15:54 ` [Bug c++/100470] " redi at gcc dot gnu.org 2022-09-20 9:23 ` redi at gcc dot gnu.org 2022-09-20 9:43 ` redi at gcc dot gnu.org [this message] 2022-09-20 9:50 ` redi at gcc dot gnu.org 2023-08-08 21:45 ` pinskia at gcc dot gnu.org 2023-10-26 16:07 ` johelegp at gmail dot com 2023-12-11 2:34 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100470-4-xer3VP94DN@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).