[PATCH] testsuite: Add noexcept(false) to throwing destructor
Jonathan Wakely
jwakely@redhat.com
Fri Oct 23 11:46:05 GMT 2020
I think this test is intended to check this property of the C++
standard:
"If a destructor directly invoked by stack unwinding exits via an
exception, std::terminate is invoked." [except.throw]
Since C++11 any exception escaping a destructor will call
std::terminate, so the test would terminate even if the unwinding
behaviour was wrong.
Give the destructor a potentially-throwing exception specification,
so that we know that terminate was called for the right reason.
gcc/testsuite/ChangeLog:
* g++.dg/compat/eh/filter2_y.C: Add noexcept(false) to
destructor.
Tested powerpc64le-linux. OK for trunk?
-------------- next part --------------
commit a1ef6bb4c681062c477f6a7a0859badf1bec4b09
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Oct 23 11:57:53 2020
testsuite: Add noexcept(false) to throwing destructor
I think this test is intended to check this property of the C++
standard:
"If a destructor directly invoked by stack unwinding exits via an
exception, std::terminate is invoked." [except.throw]
Since C++11 any exception escaping a destructor will call
std::terminate, so the test would terminate even if the unwinding
behaviour was wrong.
Give the destructor a potentially-throwing exception specification,
so that we know that terminate was called for the right reason.
gcc/testsuite/ChangeLog:
* g++.dg/compat/eh/filter2_y.C: Add noexcept(false) to
destructor.
diff --git a/gcc/testsuite/g++.dg/compat/eh/filter2_y.C b/gcc/testsuite/g++.dg/compat/eh/filter2_y.C
index 87c6fea1012..67a4ffedd86 100644
--- a/gcc/testsuite/g++.dg/compat/eh/filter2_y.C
+++ b/gcc/testsuite/g++.dg/compat/eh/filter2_y.C
@@ -9,6 +9,12 @@ struct a
a () { }
~a ()
+#if __cplusplus >= 201103L
+ // Give this destructor a potentially-throwing exception specification so
+ // that we verify std::terminate gets called due to an exception during
+ // unwinding, not just because the destructor is noexcept.
+ noexcept(false)
+#endif
{
try
{
More information about the Gcc-patches
mailing list