diff options
author | Keith Randall <khr@golang.org> | 2020-10-22 16:37:19 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-10-27 23:05:45 +0000 |
commit | 255afa2461eb45756bbc562d37f5988cc3ca29f7 (patch) | |
tree | f0cdc57c9f0d184f6426f032c4e9bbde6c100ce8 /test | |
parent | 8f14c1840d15233b7f3d08f0acf0b0559d465a56 (diff) | |
download | go-255afa2461eb45756bbc562d37f5988cc3ca29f7.tar.gz go-255afa2461eb45756bbc562d37f5988cc3ca29f7.zip |
[release-branch.go1.15] 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 #42169
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>
(cherry picked from commit 009d71409821a6ac4f1b32aaae2c856c20a29f92)
Reviewed-on: https://go-review.googlesource.com/c/go/+/265720
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixedbugs/issue42076.go | 21 |
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") + } +} |