diff options
author | Alberto Donizetti <alb.donizetti@gmail.com> | 2018-03-28 12:19:46 +0200 |
---|---|---|
committer | Alberto Donizetti <alb.donizetti@gmail.com> | 2018-03-28 16:56:03 +0000 |
commit | 360c19157ae5465c9548bd9e050263b9e336c9bf (patch) | |
tree | 702b28abc608f07a5871814f65952aa3712e77ae /test/escape_array.go | |
parent | f8b28e28f8e41d988ff1c08721e6f7d33f3fa7ff (diff) | |
download | go-360c19157ae5465c9548bd9e050263b9e336c9bf.tar.gz go-360c19157ae5465c9548bd9e050263b9e336c9bf.zip |
cmd/compile: print accurate escape reason for non-const-length slices
This change makes `-m -m` print a better explanation for the case
where a slice is marked as escaping and heap-allocated because it
has a non-constant len/cap.
Fixes #24578
Change-Id: I0ebafb77c758a99857d72b365817bdba7b446cc0
Reviewed-on: https://go-review.googlesource.com/102895
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Diffstat (limited to 'test/escape_array.go')
-rw-r--r-- | test/escape_array.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/escape_array.go b/test/escape_array.go index 0204c690cd..c2c3e2c857 100644 --- a/test/escape_array.go +++ b/test/escape_array.go @@ -120,3 +120,10 @@ func doesMakeSlice(x *string, y *string) { // ERROR "leaking param: x" "leaking b := make([]*string, 65537) // ERROR "make\(\[\]\*string, 65537\) escapes to heap" b[0] = y } + +func nonconstArray() { + n := 32 + s1 := make([]int, n) // ERROR "make\(\[\]int, n\) escapes to heap" + s2 := make([]int, 0, n) // ERROR "make\(\[\]int, 0, n\) escapes to heap" + _, _ = s1, s2 +} |