Patchwork Go patch committed: Fix field tracking in global var initializer

login
register
mail settings
Submitter Ian Taylor
Date Dec. 3, 2012, 7:21 a.m.
Message ID <mcrtxs3sis0.fsf@google.com>
Download mbox | patch
Permalink /patch/203296/
State New
Headers show

Comments

Ian Taylor - Dec. 3, 2012, 7:21 a.m.
This patch to the Go compiler avoids a crash if a tracked field is
referenced in the initializer for a global variable.  Bootstrapped on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 879fac2f2103 go/expressions.cc
--- a/go/expressions.cc	Sun Dec 02 22:55:02 2012 -0800
+++ b/go/expressions.cc	Sun Dec 02 23:19:27 2012 -0800
@@ -10651,7 +10651,8 @@ 
   // them if they are not referenced.  The effect is that the only
   // strings, indicating field references, that will wind up in the
   // executable will be those for functions that are actually needed.
-  function->func_value()->set_in_unique_section();
+  if (function != NULL)
+    function->func_value()->set_in_unique_section();
   var->set_in_unique_section();
 
   return this;