public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pobrn at protonmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/115222] New: clang does not think libstdc++'s std::optional is nothrow destructible Date: Sat, 25 May 2024 00:53:31 +0000 [thread overview] Message-ID: <bug-115222-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115222 Bug ID: 115222 Summary: clang does not think libstdc++'s std::optional is nothrow destructible Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pobrn at protonmail dot com Target Milestone: --- clang and gcc disagree whether libstdc++'s std::optional<T> is nothrow destructible when T is not. My reading of https://eel.is/c++draft/optional.dtor suggests that the destructor should be `noexcept(true)` (by omission). Consider the following piece of C++ code: ``` #include <optional> #include <type_traits> struct A { ~A() noexcept(false); }; static_assert(std::is_nothrow_destructible_v<std::optional<A>>); ``` the assertion passes on gcc, while it fails on clang: https://gcc.godbolt.org/z/1ndxK1avM Now I have tried to reduce the input, and arrived at something like this ( https://gcc.godbolt.org/z/orx5j1Eaf ): ``` template <typename _Tp> _Tp declval() noexcept; template <typename _Tp> inline constexpr bool is_nothrow_destructible_v = noexcept(declval<_Tp>()); template <typename _Tp> struct _Optional_payload_base { union _Storage { _Tp _M_value; } _M_payload; }; template <typename _Tp> struct _Optional_payload : _Optional_payload_base<_Tp> { ~_Optional_payload(); }; struct A { ~A() noexcept(false); }; static_assert(is_nothrow_destructible_v<_Optional_payload<A>>); ``` The assertion passes on gcc, but fails on clang (and edg).
next reply other threads:[~2024-05-25 0:53 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-25 0:53 pobrn at protonmail dot com [this message] 2024-05-25 1:12 ` [Bug c++/115222] " pinskia at gcc dot gnu.org 2024-05-25 2:07 ` [Bug c++/115222] gcc ignores noexcept on fields' deconstructors in an union pinskia at gcc dot gnu.org 2024-05-25 2:16 ` pinskia at gcc dot gnu.org 2024-05-25 2:29 ` pinskia at gcc dot gnu.org 2024-05-25 12:44 ` harald at gigawatt dot nl 2024-06-10 16:35 ` pinskia 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-115222-4@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).