diff options
author | Keith Randall <keithr@alum.mit.edu> | 2017-03-24 09:00:17 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2017-03-24 17:14:00 +0000 |
commit | a69754e30c9582e830ba244578724449955d4160 (patch) | |
tree | f83e81435dc62f0378d4a81dd900d9709a7fa696 /test/escape5.go | |
parent | 7202341de92927484a3eed101d3b77653b8b8bd1 (diff) | |
download | go-a69754e30c9582e830ba244578724449955d4160.tar.gz go-a69754e30c9582e830ba244578724449955d4160.zip |
cmd/compile: unnamed parameters do not escape
Fixes #19687
Change-Id: I2e4769b4ec5812506df4ac5dc6bc6a7c5774ecb0
Reviewed-on: https://go-review.googlesource.com/38600
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test/escape5.go')
-rw-r--r-- | test/escape5.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/escape5.go b/test/escape5.go index c4bf17b2ac..7d6ef554a5 100644 --- a/test/escape5.go +++ b/test/escape5.go @@ -9,6 +9,8 @@ package foo +import "runtime" + func noleak(p *int) int { // ERROR "p does not escape" return *p } @@ -149,3 +151,15 @@ func f10() { var y = make([]byte, 1<<30) // ERROR "make\(\[\]byte, 1 << 30\) escapes to heap" _ = x[0] + y[0] } + +// Test for issue 19687 (passing to unnamed parameters does not escape). +func f11(**int) { +} +func f12(_ **int) { +} +func f13() { + var x *int + f11(&x) // ERROR "&x does not escape" + f12(&x) // ERROR "&x does not escape" + runtime.KeepAlive(&x) // ERROR "&x does not escape" +} |