From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25E013885C24; Sat, 25 May 2024 00:53:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25E013885C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716598412; bh=SlbW0+WccF2utiVpbY/2TwOJQr9/b9GSWSk33W/qO5E=; h=From:To:Subject:Date:From; b=p9KALTrN102N83LhQkhtPSNzHMsD2vBEM5ZgSuiidEtNNH2gOE8qFpG0sFZOy4P2r KvXs2rnQDtjbY1zIsenM1tb3SH+6Yom+cYmzg4+E3PfPBXbVMsPJhm6EclIG8YeHwx r2XRVi+ZRRrhdD2dw/GNG3FJrW5XGp6Y98VP4B7I= From: "pobrn at protonmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pobrn at protonmail dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D115222 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 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 #include struct A { ~A() noexcept(false); }; static_assert(std::is_nothrow_destructible_v>); ``` 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 _Tp declval() noexcept; template inline constexpr bool is_nothrow_destructible_v =3D noexcept(declval<_Tp>()= ); template struct _Optional_payload_base { union _Storage { _Tp _M_value; } _M_payload; }; template struct _Optional_payload : _Optional_payload_base<_Tp> { ~_Optional_payload(); }; struct A { ~A() noexcept(false); }; static_assert(is_nothrow_destructible_v<_Optional_payload>); ``` The assertion passes on gcc, but fails on clang (and edg).=