diff mbox

[C++,Patch/RFC] PR 58671

Message ID 54B66B5D.4040100@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Jan. 14, 2015, 1:13 p.m. UTC
Hi,

in order to avoid ICEing in var_defined_without_dynamic_init for 
self-initialized thread_local vars, shall we simply return false for those?

Thanks,
Paolo.

//////////////////////

Comments

Jason Merrill Jan. 14, 2015, 3 p.m. UTC | #1
On 01/14/2015 08:13 AM, Paolo Carlini wrote:
> in order to avoid ICEing in var_defined_without_dynamic_init for
> self-initialized thread_local vars, shall we simply return false for those?

What is clearing DECL_INITIALIZED_P  for such variables?

Jason
Paolo Carlini Jan. 14, 2015, 3:08 p.m. UTC | #2
Hi,

On 01/14/2015 04:00 PM, Jason Merrill wrote:
> On 01/14/2015 08:13 AM, Paolo Carlini wrote:
>> in order to avoid ICEing in var_defined_without_dynamic_init for
>> self-initialized thread_local vars, shall we simply return false for 
>> those?
>
> What is clearing DECL_INITIALIZED_P  for such variables?
I can look again, but as far as I remember nothing is clearing it, it 
just stay false because the ICE happens while we process the 'i' on the 
right hand side and the DECL_INITIALIZED_P becomes true only in 
cp_finish_decl.

Paolo.
Jason Merrill Jan. 14, 2015, 9:23 p.m. UTC | #3
On 01/14/2015 10:08 AM, Paolo Carlini wrote:
> I can look again, but as far as I remember nothing is clearing it, it
> just stay false because the ICE happens while we process the 'i' on the
> right hand side and the DECL_INITIALIZED_P becomes true only in
> cp_finish_decl.

Ah, please say that in the comment.  OK with that change.

Jason
diff mbox

Patch

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;