===================================================================
@@ -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
}
===================================================================
@@ -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);