aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2025-07-29 18:45:23 +0700
committerGopher Robot <gobot@golang.org>2025-08-05 08:28:50 -0700
commit5ab9f23977694ab87614fd30e081d294eb313efd (patch)
tree3702479ac75143397f09baa0c3fcdfa63231f146 /src/runtime/testdata
parentfcc036f03b07e58f76ed94bc9a9483ddef96f81c (diff)
downloadgo-5ab9f23977694ab87614fd30e081d294eb313efd.tar.xz
cmd/compile, runtime: add checkptr instrumentation for unsafe.Add
Fixes #74431 Change-Id: Id651ea0b82599ccaff8816af0a56ddbb149b6f89 Reviewed-on: https://go-review.googlesource.com/c/go/+/692015 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: t hepudds <thepudds1460@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprog/checkptr.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/checkptr.go b/src/runtime/testdata/testprog/checkptr.go
index 60e71e66d7..ff99fa8c7b 100644
--- a/src/runtime/testdata/testprog/checkptr.go
+++ b/src/runtime/testdata/testprog/checkptr.go
@@ -16,6 +16,7 @@ func init() {
register("CheckPtrAlignmentNilPtr", CheckPtrAlignmentNilPtr)
register("CheckPtrArithmetic", CheckPtrArithmetic)
register("CheckPtrArithmetic2", CheckPtrArithmetic2)
+ register("CheckPtrArithmeticUnsafeAdd", CheckPtrArithmeticUnsafeAdd)
register("CheckPtrSize", CheckPtrSize)
register("CheckPtrSmall", CheckPtrSmall)
register("CheckPtrSliceOK", CheckPtrSliceOK)
@@ -79,6 +80,11 @@ func CheckPtrArithmetic2() {
sink2 = unsafe.Pointer(uintptr(p) & ^one)
}
+func CheckPtrArithmeticUnsafeAdd() {
+ data := make([]byte, 128)
+ sink2 = (*byte)(unsafe.Add(unsafe.Pointer(unsafe.SliceData(data)), len(data)))
+}
+
func CheckPtrSize() {
p := new(int64)
sink2 = p