The Go frontend had a bug when initializing a global variable to a function call when some of the arguments to the call were themselves function calls. The code which enforces function call ordering was accidentally causing the outermost function to be called twice. This patch fixes the bug. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 50541425d168 go/gogo.cc --- a/go/gogo.cc Wed Sep 28 06:13:03 2011 -0700 +++ b/go/gogo.cc Tue Oct 04 16:13:56 2011 -0700 @@ -2063,6 +2063,8 @@ return TRAVERSE_SKIP_COMPONENTS; } + Expression* orig_init = init; + for (Find_eval_ordering::const_iterator p = find_eval_ordering.begin(); p != find_eval_ordering.end(); ++p) @@ -2087,6 +2089,9 @@ var->add_preinit_statement(this->gogo_, s); } + if (init != orig_init) + var->set_init(init); + return TRAVERSE_SKIP_COMPONENTS; }