Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 219581) +++ cp/decl2.c (working copy) @@ -3094,8 +3094,10 @@ var_defined_without_dynamic_init (tree var) counts as dynamic initialization. */ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (var))) return false; - /* If it's in this TU, its initializer has been processed. */ - gcc_assert (DECL_INITIALIZED_P (var)); + /* If it's in this TU, its initializer has been processed, unless + it's a case of self-initialization. */ + if (!DECL_INITIALIZED_P (var)) + return false; /* If it has no initializer or a constant one, it's not dynamic. */ return (!DECL_NONTRIVIALLY_INITIALIZED_P (var) || DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (var)); Index: testsuite/g++.dg/tls/thread_local-ice3.C =================================================================== --- testsuite/g++.dg/tls/thread_local-ice3.C (revision 0) +++ testsuite/g++.dg/tls/thread_local-ice3.C (working copy) @@ -0,0 +1,5 @@ +// PR c++/58671 +// { dg-do compile { target c++11 } } +// { dg-require-effective-target tls } + +thread_local int i = i;