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]

C++ PATCH for c++/58672 (ICE with invalid thread_local)


In this testcase, an error caused us to decide that a variable needs initialization but not a TLS init function. We should handle that gracefully.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit cc60625316aa72c2142bd90a30e3756358caac23
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jan 31 11:36:54 2014 -0500

    	PR c++/58672
    	* decl2.c (handle_tls_init): Handle null init fn.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 2216591..35707a0 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4036,6 +4036,8 @@ handle_tls_init (void)
       if (TREE_PUBLIC (var))
 	{
           tree single_init_fn = get_tls_init_fn (var);
+	  if (single_init_fn == NULL_TREE)
+	    continue;
 	  cgraph_node *alias
 	    = cgraph_same_body_alias (cgraph_get_create_node (fn),
 				      single_init_fn, fn);
diff --git a/gcc/testsuite/g++.dg/tls/thread_local-ice2.C b/gcc/testsuite/g++.dg/tls/thread_local-ice2.C
new file mode 100644
index 0000000..53bc297
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/thread_local-ice2.C
@@ -0,0 +1,11 @@
+// PR c++/58672
+// { dg-options "-std=c++11" }
+// { dg-require-effective-target tls }
+
+struct A
+{
+  A(int);
+  i;				// { dg-error "" }
+};
+
+thread_local A a(0);

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