diff mbox

Fix PR45854

Message ID alpine.LNX.2.00.1010011401290.8982@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Oct. 1, 2010, 12:01 p.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, committed.

Richard.

2010-10-01  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/45854
	* tree-eh.c (cleanup_empty_eh): Avoid degenerate case.

	* g++.dg/torture/pr45854.C: New testcase.
diff mbox

Patch

Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c	(revision 164873)
+++ gcc/tree-eh.c	(working copy)
@@ -3720,7 +3720,13 @@  cleanup_empty_eh (eh_landing_pad lp)
 
   /* If the block is totally empty, look for more unsplitting cases.  */
   if (gsi_end_p (gsi))
-    return cleanup_empty_eh_unsplit (bb, e_out, lp);
+    {
+      /* For the degenerate case of an infinite loop bail out.  */
+      if (e_out->dest == bb)
+	return false;
+
+      return cleanup_empty_eh_unsplit (bb, e_out, lp);
+    }
 
   /* The block should consist only of a single RESX statement.  */
   resx = gsi_stmt (gsi);
Index: gcc/testsuite/g++.dg/torture/pr45854.C
===================================================================
--- gcc/testsuite/g++.dg/torture/pr45854.C	(revision 0)
+++ gcc/testsuite/g++.dg/torture/pr45854.C	(revision 0)
@@ -0,0 +1,30 @@ 
+// { dg-do compile }
+
+template < typename = void >
+struct X { } ;
+struct Y
+{
+  Y () ;
+} ;
+template < typename = X < > >
+struct T
+{
+  void f ()
+    {
+      f () ;
+    }
+} ;
+struct S
+{
+  S ( X < > = X < > ()) ;
+  ~S ()
+    {
+      T < > () . f () ;
+    }
+} ;
+struct
+{
+  S s ;
+  Y y ;
+} a ;
+