<h3 dir="auto">Version:</h3>
<p dir="auto"><code class="notranslate">go version devel +4ffa5eb Sun Mar 27 05:31:54 2016 +0000 linux/amd64 </code></p>
<h3 dir="auto">Env:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GOARCH=&quot;amd64&quot;
GOBIN=&quot;&quot;
GOEXE=&quot;&quot;
GOHOSTARCH=&quot;amd64&quot;
GOHOSTOS=&quot;linux&quot;
GOOS=&quot;linux&quot;
GOPATH=&quot;/home/shaharko/gopath&quot;
GORACE=&quot;&quot;
GOROOT=&quot;/home/shaharko/src/go_master&quot;
GOTOOLDIR=&quot;/home/shaharko/src/go_master/pkg/tool/linux_amd64&quot;
CC=&quot;gcc&quot;
GOGCCFLAGS=&quot;-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build742740600=/tmp/go-build -gno-record-gcc-switches&quot;
CXX=&quot;g++&quot;
CGO_ENABLED=&quot;1&quot;
"><pre class="notranslate"><code class="notranslate">GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/shaharko/gopath"
GORACE=""
GOROOT="/home/shaharko/src/go_master"
GOTOOLDIR="/home/shaharko/src/go_master/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build742740600=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ go tool nm pkg/linux_amd64/io.a | grep gclocals | awk '{ print $3 }' |  wc -l
142 # total gclocals
$ go tool nm pkg/linux_amd64/io.a | grep gclocals | awk '{ print $3 }' | uniq | wc -l
38  # unique gclocals"><pre class="notranslate"><code class="notranslate">$ go tool nm pkg/linux_amd64/io.a | grep gclocals | awk '{ print $3 }' |  wc -l
142 # total gclocals
$ go tool nm pkg/linux_amd64/io.a | grep gclocals | awk '{ print $3 }' | uniq | wc -l
38  # unique gclocals
</code></pre></div>
<p dir="auto">The symbol duplication factor is ~3.5x.</p>
<pre class="notranslate"><a href="http://play.golang.org/p/VMk-h3Js4z" rel="nofollow">http://play.golang.org/p/VMk-h3Js4z</a>

produces the following output:

6 2 5 3 4 1

which appears to initialize the variables a to f in the order they are mentioned in the
composite literal in makeOrder.

However, the spec says ( <a href="http://tip.golang.org/ref/spec#Program_execution" rel="nofollow">http://tip.golang.org/ref/spec#Program_execution</a> ):

"If the initializer of A depends on B, A will be set after B. Dependency analysis
does not depend on the actual values of the items being initialized, only on their
appearance in the source. A depends on B if the value of A contains a mention of B,
contains a value whose initializer mentions B, or mentions a function that mentions B,
recursively. It is an error if such dependencies form a cycle. If two items are not
interdependent, they will be initialized in the order they appear in the source,
possibly in multiple files, as presented to the compiler."

- dependency only depends on the appearance in the source: makeOrder depends on a...f
because it contains a mention of a...f. It doesn't say it depends on the order of those
mentions.

- not interdependent items are initialized in the order they appear in the source: a...f
are not interdependent, so they should be initialized in the order they appear: a, b, c,
d, e, f

Therefore the correct result should be:

1 2 3 4 5 6

gccgo produces this correct order.</pre>