diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-08-16 17:52:13 +0800 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2022-08-31 17:15:15 +0000 |
| commit | c7085329367e14f0aa828a3793cf66d9f82f05c2 (patch) | |
| tree | 94f2e9ae0cfc74e1b3cd477480f718a2bd4b6814 /src/runtime/testdata/testprog/checkptr.go | |
| parent | 301ca7513f427f6511fb67cc0385151403cd1729 (diff) | |
| download | go-c7085329367e14f0aa828a3793cf66d9f82f05c2.tar.xz | |
cmd/compile: add support for unsafe.{String,StringData,SliceData}
For #53003
Change-Id: I13a761daca8b433b271a1feb711c103d9820772d
Reviewed-on: https://go-review.googlesource.com/c/go/+/423774
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/testdata/testprog/checkptr.go')
| -rw-r--r-- | src/runtime/testdata/testprog/checkptr.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/checkptr.go b/src/runtime/testdata/testprog/checkptr.go index b27e5f74f8..60e71e66d7 100644 --- a/src/runtime/testdata/testprog/checkptr.go +++ b/src/runtime/testdata/testprog/checkptr.go @@ -20,6 +20,8 @@ func init() { register("CheckPtrSmall", CheckPtrSmall) register("CheckPtrSliceOK", CheckPtrSliceOK) register("CheckPtrSliceFail", CheckPtrSliceFail) + register("CheckPtrStringOK", CheckPtrStringOK) + register("CheckPtrStringFail", CheckPtrStringFail) register("CheckPtrAlignmentNested", CheckPtrAlignmentNested) } @@ -98,6 +100,17 @@ func CheckPtrSliceFail() { sink2 = unsafe.Slice(p, 100) } +func CheckPtrStringOK() { + p := new([4]byte) + sink2 = unsafe.String(&p[1], 3) +} + +func CheckPtrStringFail() { + p := new(byte) + sink2 = p + sink2 = unsafe.String(p, 100) +} + func CheckPtrAlignmentNested() { s := make([]int8, 100) p := unsafe.Pointer(&s[0]) |
