aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2020-11-13 16:54:48 -0500
committerDavid Chase <drchase@google.com>2020-11-14 17:24:37 +0000
commit92c732e901a732855f4b813e6676264421eceae9 (patch)
tree6fdc0828d5c90fef75e0d916c09818909541a339 /test
parent782cf560db4c919790fdb476d1bbe18e5ddf5ffd (diff)
downloadgo-92c732e901a732855f4b813e6676264421eceae9.tar.gz
go-92c732e901a732855f4b813e6676264421eceae9.zip
cmd/compile: fix load of interface{}-typed OpIData in expand_calls
In certain cases, the declkared type of an OpIData is interface{}. This was not expected (since interface{} is a pair, right?) and thus caused a crash. What is intended is that these be treated as a byteptr, so do that instead (this is what happens in 1.15). Fixes #42568. Change-Id: Id7c9e5dc2cbb5d7c71c6748832491ea62b0b339f Reviewed-on: https://go-review.googlesource.com/c/go/+/270057 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue42568.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/fixedbugs/issue42568.go b/test/fixedbugs/issue42568.go
new file mode 100644
index 0000000000..834fdc58f3
--- /dev/null
+++ b/test/fixedbugs/issue42568.go
@@ -0,0 +1,25 @@
+// compile
+
+// Copyright 2020 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.
+
+// Ensure that late expansion correctly handles an OpIData with type interface{}
+
+package p
+
+type S struct{}
+
+func (S) M() {}
+
+type I interface {
+ M()
+}
+
+func f(i I) {
+ o := i.(interface{})
+ if _, ok := i.(*S); ok {
+ o = nil
+ }
+ println(o)
+}