From 5afa5554289c91706ef6244b24ccf91181123b68 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 28 Aug 2021 14:55:10 +0700 Subject: [PATCH] cmd/compile: fix wrong check for b.Controls in isBlockMultiValueExit b.Controls has type [2]*Value, thus len(b.Controls) > 0 is always true. The right check should be b.Controls[0] != nil, though, this is also always true, since when we always set control value for BlockRet and BlockRetJmp when state.exit is called. Though checkFunc also checks for nil control value of ret/retjmp, but it happens later after expand_calls pass, so better to be defensive here, just in case. Change-Id: Ie4a292a3494dfbf5e6d872cde498703023b84d00 Reviewed-on: https://go-review.googlesource.com/c/go/+/345433 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/expand_calls.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index eba36ce33b..a1ce27cc4a 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -24,7 +24,7 @@ type selKey struct { type Abi1RO uint8 // An offset within a parameter's slice of register indices, for abi1. func isBlockMultiValueExit(b *Block) bool { - return (b.Kind == BlockRet || b.Kind == BlockRetJmp) && len(b.Controls) > 0 && b.Controls[0].Op == OpMakeResult + return (b.Kind == BlockRet || b.Kind == BlockRetJmp) && b.Controls[0] != nil && b.Controls[0].Op == OpMakeResult } func badVal(s string, v *Value) error { -- 2.48.1