]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix escape reason for MAKESLICE with no cap
authorAlberto Donizetti <alb.donizetti@gmail.com>
Sat, 26 Sep 2020 07:42:59 +0000 (09:42 +0200)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Mon, 28 Sep 2020 06:38:58 +0000 (06:38 +0000)
commite572218d1273bf54bf8cafd39f93f22de196dd55
treef0afe8bdd7f779a5c73ec11bd08bd716f7e1d055
parent5755bad42adc23ad4a0c32149ac8cf78ece5d0b0
cmd/compile: fix escape reason for MAKESLICE with no cap

When explaining why the slice from a make() call escapes for the -m -m
message, we print "non-const size" if any one of Isconst(n.Left) and
Isconst(n.Right) return false; but for OMAKESLICE nodes with no cap,
n.Right is nil, so Isconst(n.Right, CTINT) will be always false.

Only call Isconst on n.Right if it's not nil.

Fixes #41635

Change-Id: I8729801a9b234b68ae40adad64d66fa7653adf09
Reviewed-on: https://go-review.googlesource.com/c/go/+/257641
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
src/cmd/compile/internal/gc/escape.go
test/fixedbugs/issue41635.go [new file with mode: 0644]