[PATCH] D39961: [libcxx] Fix rethrow_if_nested test on Windows.

Andrey Khalyavin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 13 08:38:26 PST 2017


halyavin created this revision.

Stack overflow is caused by B copy constructor invoking default constructor of std::nested_exception which tries to capture current exception. Capturing current exception copies it and since our current exception is B, we call B's copy constructor and cause infinite recursion.

After fix, "throw b" no longer captures current exception (it copies it from B(5) object where it is empty) and so throw_if_nested terminates the test.


https://reviews.llvm.org/D39961

Files:
  test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp


Index: test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
===================================================================
--- test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
+++ test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -9,9 +9,6 @@
 
 // UNSUPPORTED: libcpp-no-exceptions
 
-// This test fails due to a stack overflow
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <exception>
 
 // class nested_exception;
@@ -40,7 +37,7 @@
 {
 public:
     explicit B(int data) : A(data) {}
-    B(const B& b) : A(b) {}
+    B(const B& b) : std::nested_exception(b), A(b) {}
 };
 
 class C
@@ -104,7 +101,7 @@
         {
             try
             {
-                throw b;
+                throw B(4);
             }
             catch (const A& a)
             {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39961.122658.patch
Type: text/x-patch
Size: 868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171113/2ed07eb4/attachment-0001.bin>


More information about the cfe-commits mailing list