re PR c++/52643 (Stack overflow ICE in cc1plus when templates, exceptions, and contin...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 14 Oct 2012 13:40:55 +0000 (13:40 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 14 Oct 2012 13:40:55 +0000 (13:40 +0000)
2012-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52643
* g++.dg/opt/pr52643.C: New.

From-SVN: r192432

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr52643.C [new file with mode: 0644]

index 033c8522fa2363f0d0bf7c16420068acc525f933..3a7dd939a844fdb46ea3ec49874a60c6ed681da5 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52643
+       * g++.dg/opt/pr52643.C: New.
+
 2012-10-12  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/54602
diff --git a/gcc/testsuite/g++.dg/opt/pr52643.C b/gcc/testsuite/g++.dg/opt/pr52643.C
new file mode 100644 (file)
index 0000000..271dd76
--- /dev/null
@@ -0,0 +1,64 @@
+// PR c++/52643
+// { dg-options "-O" }
+
+template<class T> class already_AddRefd {};
+
+template<class T>
+class ObjRef
+{
+public:
+  ObjRef() {}
+
+  ObjRef(const already_AddRefd<T> aar) {}
+
+  ~ObjRef()
+  {
+    T* mPtr;
+    mPtr->release_ref();
+  }
+
+  operator T* () const
+  {
+    return __null;
+  }
+
+  template<class U>
+  void operator= (const already_AddRefd<U>& newAssign) {}
+};
+
+class MyRetClass {
+public:
+  void release_ref();
+};
+
+class MyClass
+{
+  void appendChild();
+  void getTripleOutOfByPredicate();
+  already_AddRefd<MyRetClass> getNextTriple();
+};
+
+void
+MyClass::getTripleOutOfByPredicate()
+{
+  ObjRef<MyRetClass> t (getNextTriple());
+
+  if (t == __null)
+    throw MyRetClass();
+}
+
+void
+MyClass::appendChild()
+{
+  while (1)
+  {
+    try
+    {
+      ObjRef<MyRetClass> t (getNextTriple());
+      continue;
+    }
+    catch (MyRetClass)
+    {
+    }
+  }
+}