diff mbox

[C++] PR 58672

Message ID 52EBD8DE.2030103@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Jan. 31, 2014, 5:09 p.m. UTC
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.

////////////////////////
/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.

Comments

Jason Merrill Jan. 31, 2014, 5:32 p.m. UTC | #1
Oops, sorry I was slow to claim this PR...

Jason
Paolo Carlini Jan. 31, 2014, 8:50 p.m. UTC | #2
Hi,

> On 31/gen/2014, at 18:32, Jason Merrill <jason@redhat.com> wrote:
> 
> Oops, sorry I was slow to claim this PR...

No problem, nice to see the bug going completely away!

Well, you may want to have a look to my pending work on c++/51219 ;)

  http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01693.html
  http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01808.html

Thanks,
Paolo.
diff mbox

Patch

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