From: Matthew Dempsky Date: Mon, 5 Dec 2016 23:57:45 +0000 (-0800) Subject: cmd/compile: fix static-initialization compilation failure X-Git-Tag: go1.8beta2~85 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=749720a0362557eabbf87ef9f1494b18444c0adb;p=gostls13.git cmd/compile: fix static-initialization compilation failure Fixes #13263. Change-Id: Ie1cafc62b6bfe6c5381c35d9a95563267b4cc9b0 Reviewed-on: https://go-review.googlesource.com/33970 Reviewed-by: Robert Griesemer Reviewed-by: Emmanuel Odeke Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go index 1192f3fac9..350c867725 100644 --- a/src/cmd/compile/internal/gc/sinit.go +++ b/src/cmd/compile/internal/gc/sinit.go @@ -295,7 +295,9 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool { if staticcopy(l, r, out) { return true } - *out = append(*out, nod(OAS, l, r)) + // We may have skipped past one or more OCONVNOPs, so + // use conv to ensure r is assignable to l (#13263). + *out = append(*out, nod(OAS, l, conv(r, l.Type))) return true case OLITERAL: diff --git a/test/fixedbugs/issue13263.go b/test/fixedbugs/issue13263.go new file mode 100644 index 0000000000..1933f2b5c5 --- /dev/null +++ b/test/fixedbugs/issue13263.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2016 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 + +var ( + x uint + y = x + z = uintptr(y) + a = uint32(y) + b = uint64(y) +)