Patchwork [C++,testcase] PR 52643

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 14, 2012, 1:42 p.m.
Message ID <507AC13F.3020102@oracle.com>
Download mbox | patch
Permalink /patch/191361/
State New
Headers show

Comments

Paolo Carlini - Oct. 14, 2012, 1:42 p.m.
Hi,

testcase added, issue closed as fixed. Tested x86_64-linux.

Thanks,
Paolo.

////////////////////////
2012-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

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

Patch

Index: g++.dg/opt/pr52643.C
===================================================================
--- g++.dg/opt/pr52643.C	(revision 0)
+++ g++.dg/opt/pr52643.C	(working copy)
@@ -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)
+    {
+    }
+  }
+}