aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIskander Sharipov <iskander.sharipov@intel.com>2018-09-07 20:36:56 +0300
committerIan Lance Taylor <iant@golang.org>2018-09-07 18:49:12 +0000
commitb7f9c640b7d4d1ba721dc158a12df0a2d2d69a2f (patch)
treea54922cc7ab8ecd5e2f4261a3dec215d928aeed2
parent7a0eb56466eb26704fad49caec228ba21831761e (diff)
downloadgo-b7f9c640b7d4d1ba721dc158a12df0a2d2d69a2f.tar.xz
test: extend noescape bytes.Buffer test suite
Added some more cases that should be guarded against regression. Change-Id: I9f1dda2fd0be9b6e167ef1cc018fc8cce55c066c Reviewed-on: https://go-review.googlesource.com/134017 Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--test/fixedbugs/issue7921.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/fixedbugs/issue7921.go b/test/fixedbugs/issue7921.go
index d32221a209..e30e556353 100644
--- a/test/fixedbugs/issue7921.go
+++ b/test/fixedbugs/issue7921.go
@@ -37,3 +37,20 @@ func bufferNoEscape3(xs []string) string { // ERROR "xs does not escape"
}
return b.String() // ERROR "inlining call" "string\(bytes.b.buf\[bytes\.b\.off:\]\) escapes to heap"
}
+
+func bufferNoEscape4() []byte {
+ var b bytes.Buffer
+ b.Grow(64) // ERROR "b does not escape"
+ useBuffer(&b) // ERROR "&b does not escape"
+ return b.Bytes() // ERROR "inlining call" "b does not escape"
+}
+
+func bufferNoEscape5() {
+ b := bytes.NewBuffer(make([]byte, 0, 128)) // ERROR "inlining call" "make\(\[\]byte, 0, 128\) does not escape" "&bytes.Buffer literal does not escape"
+ useBuffer(b)
+}
+
+//go:noinline
+func useBuffer(b *bytes.Buffer) { // ERROR "b does not escape"
+ b.WriteString("1234")
+}