]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: generate type alg after calling dowidth.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 15 Sep 2014 16:24:16 +0000 (18:24 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 15 Sep 2014 16:24:16 +0000 (18:24 +0200)
Previously it might happen before calling dowidth and
result in a compiler crash.

Fixes #8060.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/110980044

src/cmd/gc/reflect.c
test/fixedbugs/issue8060.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue8060.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue8060.go [new file with mode: 0644]

index 31e449e760ffa93c2e64147d9f12c5dfd4d150e0..4892ab75708e0cfe57e5d99cc3ca0fdb9878c49a 100644 (file)
@@ -727,12 +727,12 @@ dcommontype(Sym *s, int ot, Type *t)
        sizeofAlg = 2*widthptr;
        if(algarray == nil)
                algarray = pkglookup("algarray", runtimepkg);
+       dowidth(t);
        alg = algtype(t);
        algsym = S;
        if(alg < 0)
                algsym = dalgsym(t);
 
-       dowidth(t);
        if(t->sym != nil && !isptr[t->etype])
                sptr = dtypesym(ptrto(t));
        else
diff --git a/test/fixedbugs/issue8060.dir/a.go b/test/fixedbugs/issue8060.dir/a.go
new file mode 100644 (file)
index 0000000..22ba69e
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+var A = []*[2][1]float64{}
diff --git a/test/fixedbugs/issue8060.dir/b.go b/test/fixedbugs/issue8060.dir/b.go
new file mode 100644 (file)
index 0000000..85fb6ec
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package b
+
+import "a"
+
+var X = a.A
+
+func b() {
+       _ = [3][1]float64{}
+}
diff --git a/test/fixedbugs/issue8060.go b/test/fixedbugs/issue8060.go
new file mode 100644 (file)
index 0000000..ec52659
--- /dev/null
@@ -0,0 +1,9 @@
+// compiledir
+
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 8060: internal compiler error.
+
+package ignored