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)
             {


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)
             {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to