aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-03-17 13:27:11 -0700
committerKeith Randall <khr@golang.org>2020-03-17 20:47:06 +0000
commitf4ddc00345af8ffc77fabe2f6f21d570288159c1 (patch)
tree6971fab645578938444d742b85b9fb0d4ab2e41e /src/runtime/testdata
parent14d20dc4f38dda548f6991cc687bc71b250b1603 (diff)
downloadgo-f4ddc00345af8ffc77fabe2f6f21d570288159c1.tar.gz
go-f4ddc00345af8ffc77fabe2f6f21d570288159c1.zip
runtime: don't report a pointer alignment error for pointer-free base type
Fixes #37298 Change-Id: I8ba9c8b106e16cea7dd25473c7390b0f2ba9a1a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/223781 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprog/checkptr.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/runtime/testdata/testprog/checkptr.go b/src/runtime/testdata/testprog/checkptr.go
index 177db38e5a..45e6fb1aa5 100644
--- a/src/runtime/testdata/testprog/checkptr.go
+++ b/src/runtime/testdata/testprog/checkptr.go
@@ -7,18 +7,25 @@ package main
import "unsafe"
func init() {
- register("CheckPtrAlignment", CheckPtrAlignment)
+ register("CheckPtrAlignmentNoPtr", CheckPtrAlignmentNoPtr)
+ register("CheckPtrAlignmentPtr", CheckPtrAlignmentPtr)
register("CheckPtrArithmetic", CheckPtrArithmetic)
register("CheckPtrSize", CheckPtrSize)
register("CheckPtrSmall", CheckPtrSmall)
}
-func CheckPtrAlignment() {
+func CheckPtrAlignmentNoPtr() {
var x [2]int64
p := unsafe.Pointer(&x[0])
sink2 = (*int64)(unsafe.Pointer(uintptr(p) + 1))
}
+func CheckPtrAlignmentPtr() {
+ var x [2]int64
+ p := unsafe.Pointer(&x[0])
+ sink2 = (**int64)(unsafe.Pointer(uintptr(p) + 1))
+}
+
func CheckPtrArithmetic() {
var x int
i := uintptr(unsafe.Pointer(&x))