aboutsummaryrefslogtreecommitdiff
path: root/test/escape_slice.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2021-03-14 14:24:47 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2021-04-21 00:53:48 +0000
commitfaa4fa1a6e94fce4f6fa22524a2bece5125213b6 (patch)
treeecd5c4b860564b5b1926725f6ffafcebfac3b3d9 /test/escape_slice.go
parent1c268431f49ee2fc843eac52a0854aea3d02a6e0 (diff)
downloadgo-faa4fa1a6e94fce4f6fa22524a2bece5125213b6.tar.gz
go-faa4fa1a6e94fce4f6fa22524a2bece5125213b6.zip
cmd/compile: allow conversion from slice to array ptr
Panic if the slice is too short. Updates #395 Change-Id: I90f4bff2da5d8f3148ba06d2482084f32b25c29a Reviewed-on: https://go-review.googlesource.com/c/go/+/301650 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/escape_slice.go')
-rw-r--r--test/escape_slice.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/escape_slice.go b/test/escape_slice.go
index 6ce852e9c5..d60414736c 100644
--- a/test/escape_slice.go
+++ b/test/escape_slice.go
@@ -101,6 +101,10 @@ func slice11() {
_ = s
}
+func slice12(x []int) *[1]int { // ERROR "leaking param: x to result ~r1 level=0$"
+ return (*[1]int)(x)
+}
+
func envForDir(dir string) []string { // ERROR "dir does not escape"
env := os.Environ()
return mergeEnvLists([]string{"PWD=" + dir}, env) // ERROR ".PWD=. \+ dir escapes to heap" "\[\]string{...} does not escape"