aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-10-22 16:37:19 -0700
committerKeith Randall <khr@golang.org>2020-10-27 21:29:13 +0000
commit009d71409821a6ac4f1b32aaae2c856c20a29f92 (patch)
tree3a10a3e6fce63c0d4a4bd5d93f01c100a902afd3 /test
parent933721b8c7f981229974e2603850c2e9a7ffc5a1 (diff)
downloadgo-009d71409821a6ac4f1b32aaae2c856c20a29f92.tar.gz
go-009d71409821a6ac4f1b32aaae2c856c20a29f92.zip
cmd/compile, runtime: store pointers to go:notinheap types indirectly
pointers to go:notinheap types should be treated as scalars. That means they shouldn't be stored directly in interfaces, or directly in reflect.Value.ptr. Also be sure to use uintpr to compare such pointers in reflect.DeepEqual. Fixes #42076 Change-Id: I53735f6d434e9c3108d4940bd1bae14c61ef2a74 Reviewed-on: https://go-review.googlesource.com/c/go/+/264480 Trust: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue42076.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/fixedbugs/issue42076.go b/test/fixedbugs/issue42076.go
new file mode 100644
index 0000000000..3e954813c9
--- /dev/null
+++ b/test/fixedbugs/issue42076.go
@@ -0,0 +1,21 @@
+// run
+
+// 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.
+
+package main
+
+import "reflect"
+
+//go:notinheap
+type NIH struct {
+}
+
+var x, y NIH
+
+func main() {
+ if reflect.DeepEqual(&x, &y) != true {
+ panic("should report true")
+ }
+}