This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix cross build


In building a ppc cross compiler using a freshly built native compiler, I encountered an ICE in iterative_hash_expr compiling c-lex.c. I extracted the attached testcase, showing the problem is with statement expressions. Investigation showed I_H_E seeing BLOCK and BIND_EXPR nodes, which is was unprepared for. These two nodes are never considered equal by operand_equal_p, so we don't need to look into them further to refine the hash.

I'm not sure why a native i686-pc-linux-gnu bootstrap doesn't encounter this problem.

The attached patch resolves the ICE. built and tested on i686-pc-linux-gnu, ok?

nathan
2012-05-20  Nathan Sidwell  <nathan@acm.org>

	* tree.c (iterative_hash_expr): Add BLOCK and BIND_EXPR cases.

	* gcc.dg/stmt-expr-4.c: New.

Index: tree.c
===================================================================
--- tree.c	(revision 187628)
+++ tree.c	(working copy)
@@ -6998,6 +6998,11 @@ iterative_hash_expr (const_tree t, hashv
 	  }
 	return val;
       }
+    case BLOCK:
+    case BIND_EXPR:
+      /* These are never equal operands. The contain nodes we're not
+	 prepared for, so stop now.  */
+      return val;
     case MEM_REF:
       {
 	/* The type of the second operand is relevant, except for
Index: testsuite/gcc.dg/stmt-expr-4.c
===================================================================
--- testsuite/gcc.dg/stmt-expr-4.c	(revision 0)
+++ testsuite/gcc.dg/stmt-expr-4.c	(revision 0)
@@ -0,0 +1,22 @@
+
+/* { dg-options "-O2 -std=gnu99" } */
+/* Internal compiler error in iterative_hash_expr */
+
+struct tree_string
+{
+  char str[1];
+};
+
+union tree_node
+{
+  struct tree_string string;
+};
+
+char *Foo (union tree_node * num_string)
+{
+  char *str = ((union {const char * _q; char * _nq;})
+	       ((const char *)(({ __typeof (num_string) const __t
+				     = num_string;  __t; })
+			       ->string.str)))._nq;
+  return str;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]