Commit 7cdacf55 authored by Ainar Garipov's avatar Ainar Garipov Committed by Matthew Dempsky

test: add regress test for issue 28369

Also gofmt test/escape5.go.

Fixes #28369.

Change-Id: I0a11748fd2b5cf01cb5437ae15827d9db91c0c0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172358Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 5781df42
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
package foo package foo
import "runtime" import (
"runtime"
"unsafe"
)
func noleak(p *int) int { // ERROR "p does not escape" func noleak(p *int) int { // ERROR "p does not escape"
return *p return *p
...@@ -245,3 +248,17 @@ func g29000() { ...@@ -245,3 +248,17 @@ func g29000() {
x := 1 x := 1
f29000(2, x) // ERROR "x escapes to heap" f29000(2, x) // ERROR "x escapes to heap"
} }
// Issue 28369: taking an address of a parameter and converting it into a uintptr causes an
// unnecessary escape.
var sink28369 uintptr
func f28369(n int) int {
if n == 0 {
sink28369 = uintptr(unsafe.Pointer(&n))
return n
}
return 1 + f28369(n-1)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment