diff options
| author | Russ Cox <rsc@golang.org> | 2014-06-11 14:21:06 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-06-11 14:21:06 -0400 |
| commit | f20e4d5ecb87cae4846be07a68cb0e9132e6a8c6 (patch) | |
| tree | 1f523a0249a583c073852daac5bc718d27b4a0a5 /src/pkg/encoding | |
| parent | be91bc29a43ae582b6ca7f6adf561cfb25bd6911 (diff) | |
| download | go-f20e4d5ecb87cae4846be07a68cb0e9132e6a8c6.tar.xz | |
cmd/gc: fix &result escaping into result
There is a hierarchy of location defined by loop depth:
-1 = the heap
0 = function results
1 = local variables (and parameters)
2 = local variable declared inside a loop
3 = local variable declared inside a loop inside a loop
etc
In general if an address from loopdepth n is assigned to
something in loop depth m < n, that indicates an extended
lifetime of some form that requires a heap allocation.
Function results can be local variables too, though, and so
they don't actually fit into the hierarchy very well.
Treat the address of a function result as level 1 so that
if it is written back into a result, the address is treated
as escaping.
Fixes #8185.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/108870044
Diffstat (limited to 'src/pkg/encoding')
0 files changed, 0 insertions, 0 deletions
