]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Core DR 475 PR c++/41174 PR c++/59224
authorJason Merrill <jason@redhat.com>
Tue, 1 Apr 2014 17:28:29 +0000 (13:28 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 1 Apr 2014 17:28:29 +0000 (13:28 -0400)
Core DR 475
PR c++/41174
PR c++/59224
* libsupc++/eh_throw.cc (__cxa_throw): Set uncaughtExceptions.
* libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception)
(__cxa_allocate_exception): Don't set it here.

From-SVN: r208991

gcc/testsuite/g++.dg/eh/uncaught1.C
gcc/testsuite/g++.dg/eh/uncaught4.C [new file with mode: 0644]
libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/eh_alloc.cc
libstdc++-v3/libsupc++/eh_throw.cc

index afbf5af4d2214b390ae2ba2f056789d80a8b729a..e96af334a8ccbd8875d9610838c2cab3a1fbde17 100644 (file)
@@ -13,7 +13,7 @@ struct Check {
 
 static Check const data[] = {
   { 0, 0, false },     // construct [0]
-  { 1, 0, true  },     // [1] = [0]
+  { 1, 0, false  },    // [1] = [0]
   { 0, 0, true  },     // destruct [0]
   { 2, 1, true  },     // [2] = [1]
   { 2, 2, true  },      // destruct [2]
diff --git a/gcc/testsuite/g++.dg/eh/uncaught4.C b/gcc/testsuite/g++.dg/eh/uncaught4.C
new file mode 100644 (file)
index 0000000..227d11b
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/41174
+// { dg-do run }
+
+#include <exception>
+
+#define assert(E) if (!(E)) __builtin_abort();
+
+struct e {
+  e()
+  {
+    assert( !std::uncaught_exception() );
+    try {
+      throw 1;
+    } catch (int i) {
+      assert( !std::uncaught_exception() );
+      throw;
+    }
+  }
+};
+
+int main()
+{
+  try {
+    throw e();
+  } catch (int i) {
+    assert( !std::uncaught_exception() );
+  }
+  assert( !std::uncaught_exception() );
+}
index 4378c9b1928ea6c88ccd4eab265fdd608c1eb1ed..f5273be0c2ce6f84e846a880240e14d81b47a3ed 100644 (file)
@@ -1,3 +1,12 @@
+2014-04-01  Jason Merrill  <jason@redhat.com>
+
+       Core DR 475
+       PR c++/41174
+       PR c++/59224
+       * libsupc++/eh_throw.cc (__cxa_throw): Set uncaughtExceptions.
+       * libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception)
+       (__cxa_allocate_exception): Don't set it here.
+
 2014-03-25  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/60658
index 74474d82ec69826166de8ee7d2e17a23a1571582..9f4a52e1ee568c6924c36c69f687d742e6d2c2cf 100644 (file)
@@ -126,12 +126,6 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
        std::terminate ();
     }
 
-  // We have an uncaught exception as soon as we allocate memory.  This
-  // yields uncaught_exception() true during the copy-constructor that
-  // initializes the exception object.  See Issue 475.
-  __cxa_eh_globals *globals = __cxa_get_globals ();
-  globals->uncaughtExceptions += 1;
-
   memset (ret, 0, sizeof (__cxa_refcounted_exception));
 
   return (void *)((char *)ret + sizeof (__cxa_refcounted_exception));
@@ -188,12 +182,6 @@ __cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
        std::terminate ();
     }
 
-  // We have an uncaught exception as soon as we allocate memory.  This
-  // yields uncaught_exception() true during the copy-constructor that
-  // initializes the exception object.  See Issue 475.
-  __cxa_eh_globals *globals = __cxa_get_globals ();
-  globals->uncaughtExceptions += 1;
-
   memset (ret, 0, sizeof (__cxa_dependent_exception));
 
   return ret;
index de00602cdea3c3f263c0de17af4ef57ce0e62822..58759488373e6ac821f545cc2c6f0ba90b71baf6 100644 (file)
@@ -61,6 +61,9 @@ extern "C" void
 __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo,
                         void (_GLIBCXX_CDTOR_CALLABI *dest) (void *))
 {
+  __cxa_eh_globals *globals = __cxa_get_globals ();
+  globals->uncaughtExceptions += 1;
+
   // Definitely a primary.
   __cxa_refcounted_exception *header
     = __get_refcounted_exception_header_from_obj (obj);