summaryrefslogtreecommitdiff
path: root/test/escape_param.go
diff options
context:
space:
mode:
authorIskander Sharipov <iskander.sharipov@intel.com>2018-09-04 17:17:32 +0300
committerIskander Sharipov <iskander.sharipov@intel.com>2018-09-05 14:16:25 +0000
commit4cf33e361ada37d8fee9443a258abd167e31d033 (patch)
tree3cb5d0f7adf41a1a79013424d0ab47ff5abf8de8 /test/escape_param.go
parent3fd364988ce5dcf3aa1d4eb945d233455db30af6 (diff)
downloadgo-git-4cf33e361ada37d8fee9443a258abd167e31d033.tar.gz
cmd/compile/internal/gc: fix mayAffectMemory in esc.go
For OINDEX and other Left+Right nodes, we want the whole node to be considered as "may affect memory" if either of Left or Right affect memory. Initial implementation only considered node as such if both Left and Right were non-safe. Change-Id: Icfb965a0b4c24d8f83f3722216db068dad2eba95 Reviewed-on: https://go-review.googlesource.com/133275 Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/escape_param.go')
-rw-r--r--test/escape_param.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/escape_param.go b/test/escape_param.go
index 4eb96dff9b..dff13b6f7c 100644
--- a/test/escape_param.go
+++ b/test/escape_param.go
@@ -11,6 +11,8 @@
package escape
+func zero() int { return 0 }
+
var sink interface{}
// in -> out
@@ -62,6 +64,12 @@ func paramArraySelfAssign(p *PairOfPairs) { // ERROR "p does not escape"
p.pairs[0] = p.pairs[1] // ERROR "ignoring self-assignment in p.pairs\[0\] = p.pairs\[1\]"
}
+func paramArraySelfAssignUnsafeIndex(p *PairOfPairs) { // ERROR "leaking param content: p"
+ // Function call inside index disables self-assignment case to trigger.
+ p.pairs[zero()] = p.pairs[1]
+ p.pairs[zero()+1] = p.pairs[1]
+}
+
type PairOfPairs struct {
pairs [2]*Pair
}