Skip to content

Commit

Permalink
cmd/compile: allow ir.OSLICE2ARRPTR in mayCall
Browse files Browse the repository at this point in the history
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 <cuong.manhle.vn@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
  • Loading branch information
cuonglm committed Jun 13, 2021
1 parent 1ed0d12 commit 67b1b6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/walk/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func mayCall(n ir.Node) bool {
return true

case ir.OINDEX, ir.OSLICE, ir.OSLICEARR, ir.OSLICE3, ir.OSLICE3ARR, ir.OSLICESTR,
ir.ODEREF, ir.ODOTPTR, ir.ODOTTYPE, ir.ODIV, ir.OMOD:
ir.ODEREF, ir.ODOTPTR, ir.ODOTTYPE, ir.ODIV, ir.OMOD, ir.OSLICE2ARRPTR:
// These ops might panic, make sure they are done
// before we start marshaling args for a call. See issue 16760.
return true
Expand Down
15 changes: 15 additions & 0 deletions test/fixedbugs/issue46720.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// compile

// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

func f() {
nonce := make([]byte, 24)
g((*[24]byte)(nonce))
}

//go:noinline
func g(*[24]byte) {}

0 comments on commit 67b1b6a

Please sign in to comment.