Skip to content

Commit 67b1b6a

Browse files
committed
cmd/compile: allow ir.OSLICE2ARRPTR in mayCall
CL 301650 adds conversion from slice to array ptr. The conversion expression may appear as argument to a function call, so it will be tested by mayCall. But ir.OSLICE2ARRPTR op is not handled by mayCall, causes the compiler crashes. Updates #395 Fixes #46720 Change-Id: I39e1b3e38e224a31f3dec46dbbdc855ff3b2c6a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/327649 Trust: Cuong Manh Le <[email protected]> Trust: Josh Bleecher Snyder <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Josh Bleecher Snyder <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 1ed0d12 commit 67b1b6a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/cmd/compile/internal/walk/walk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func mayCall(n ir.Node) bool {
313313
return true
314314

315315
case ir.OINDEX, ir.OSLICE, ir.OSLICEARR, ir.OSLICE3, ir.OSLICE3ARR, ir.OSLICESTR,
316-
ir.ODEREF, ir.ODOTPTR, ir.ODOTTYPE, ir.ODIV, ir.OMOD:
316+
ir.ODEREF, ir.ODOTPTR, ir.ODOTTYPE, ir.ODIV, ir.OMOD, ir.OSLICE2ARRPTR:
317317
// These ops might panic, make sure they are done
318318
// before we start marshaling args for a call. See issue 16760.
319319
return true

test/fixedbugs/issue46720.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// compile
2+
3+
// Copyright 2021 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
func f() {
10+
nonce := make([]byte, 24)
11+
g((*[24]byte)(nonce))
12+
}
13+
14+
//go:noinline
15+
func g(*[24]byte) {}

0 commit comments

Comments
 (0)