summaryrefslogtreecommitdiff
path: root/test/escape5.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-08-08 13:46:30 -0400
committerRuss Cox <rsc@golang.org>2013-08-08 13:46:30 -0400
commitdfbe9bc5c8afd7681d5c09f61c1dc9e2e0906922 (patch)
treecf774a709822b84a9834c308a7a9489c1dfdc0a9 /test/escape5.go
parent4f63263f9925f890aa8f55d704a0fae88a1c3b40 (diff)
downloadgo-dfbe9bc5c8afd7681d5c09f61c1dc9e2e0906922.tar.gz
cmd/gc: move large stack variables to heap
Individual variables bigger than 10 MB are now moved to the heap, as if they had escaped on their own. This avoids ridiculous stacks for programs that do things like x := [1<<30]byte{} ... use x ... If 10 MB is too small, we can raise the limit. Fixes issue 6077. R=ken2 CC=golang-dev https://codereview.appspot.com/12650045
Diffstat (limited to 'test/escape5.go')
-rw-r--r--test/escape5.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/escape5.go b/test/escape5.go
index 6b327fe9e..c9646872d 100644
--- a/test/escape5.go
+++ b/test/escape5.go
@@ -142,3 +142,10 @@ func f9() {
var j T1 // ERROR "moved to heap: j"
f8(&j) // ERROR "&j escapes to heap"
}
+
+func f10() {
+ // These don't escape but are too big for the stack
+ var x [1<<30]byte // ERROR "moved to heap: x"
+ var y = make([]byte, 1<<30) // ERROR "does not escape"
+ _ = x[0] + y[0]
+}