[C++ Patch] PR 58672

Paolo Carlini paolo.carlini@oracle.com
Fri Jan 31 17:37:00 GMT 2014


Hi,

I think we can pretty easily fix the remaining minor issue in the 
thread_local meta-bug: the ICE happens because, after the error, we end 
up calling cgraph_same_body_alias from handle_tls_init with a null 
second argument (returned by get_tls_init_fn), thus 
cgraph_create_function_alias crashes immediately on the line (the whole 
function doesn't make sense for null alias):

     gcc_assert (TREE_CODE (alias) == FUNCTION_DECL);

Tested x86_64-linux.

Thanks,
Paolo.

////////////////////////
-------------- next part --------------
/cp
2014-01-31  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58672
	* decl2.c (handle_tls_init): Don't call cgraph_same_body_alias
	with a null second argument.

/testsuite
2014-01-31  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58672
	* g++.dg/tls/thread_local9.C: New.
-------------- next part --------------
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 207361)
+++ cp/decl2.c	(working copy)
@@ -4036,10 +4036,13 @@ handle_tls_init (void)
       if (TREE_PUBLIC (var))
 	{
           tree single_init_fn = get_tls_init_fn (var);
-	  cgraph_node *alias
-	    = cgraph_same_body_alias (cgraph_get_create_node (fn),
-				      single_init_fn, fn);
-	  gcc_assert (alias != NULL);
+	  if (single_init_fn)
+	    {
+	      cgraph_node *alias
+		= cgraph_same_body_alias (cgraph_get_create_node (fn),
+					  single_init_fn, fn);
+	      gcc_assert (alias != NULL);
+	    }
 	}
 #endif
     }
Index: testsuite/g++.dg/tls/thread_local9.C
===================================================================
--- testsuite/g++.dg/tls/thread_local9.C	(revision 0)
+++ testsuite/g++.dg/tls/thread_local9.C	(working copy)
@@ -0,0 +1,11 @@
+// PR c++/58672
+// { dg-options "-std=c++11" }
+// { dg-require-effective-target tls }
+
+struct A
+{
+  A(int);
+  i;  // { dg-error "does not name a type" }
+};
+
+thread_local A a(0);


More information about the Gcc-patches mailing list