scope_exit& operator=(const scope_exit&) = delete;
scope_exit& operator=(scope_exit&&) = delete;
- ~scope_exit() noexcept(noexcept(this->_M_exit_function))
+ ~scope_exit() noexcept
{
if (_M_execute_on_destruction)
_M_exit_function();
scope_fail& operator=(const scope_fail&) = delete;
scope_fail& operator=(scope_fail&&) = delete;
- ~scope_fail() noexcept(noexcept(this->_M_exit_function))
+ ~scope_fail() noexcept
{
if (std::uncaught_exceptions() > _M_uncaught_init)
_M_exit_function();
scope_success& operator=(const scope_success&) = delete;
scope_success& operator=(scope_success&&) = delete;
- ~scope_success() noexcept(noexcept(this->_M_exit_function))
+ ~scope_success() noexcept(noexcept(this->_M_exit_function()))
{
if (std::uncaught_exceptions() <= _M_uncaught_init)
_M_exit_function();
--- /dev/null
+// { dg-do compile { target c++20 } }
+
+// PR libstdc++/114152
+// Wrong exception specifiers for LFTSv3 scope guard destructors
+
+#include <experimental/scope>
+
+using namespace std::experimental;
+
+struct F {
+ void operator()() noexcept(false);
+};
+
+static_assert( noexcept(std::declval<scope_exit<F>&>().~scope_exit()) );
+static_assert( noexcept(std::declval<scope_fail<F>&>().~scope_fail()) );
+static_assert( ! noexcept(std::declval<scope_success<F>&>().~scope_success()) );
+
+struct G {
+ void operator()() noexcept(true);
+};
+
+static_assert( noexcept(std::declval<scope_exit<G>&>().~scope_exit()) );
+static_assert( noexcept(std::declval<scope_fail<G>&>().~scope_fail()) );
+static_assert( noexcept(std::declval<scope_success<G>&>().~scope_success()) );