Patchwork Fix PR45854

login
register
mail settings
Submitter Richard Guenther
Date Oct. 1, 2010, 12:01 p.m.
Message ID <alpine.LNX.2.00.1010011401290.8982@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/66391/
State New
Headers show

Comments

Richard Guenther - Oct. 1, 2010, 12:01 p.m.
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.

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 ;
+