]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow ir.OSLICE2ARRPTR in mayCall
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sun, 13 Jun 2021 03:55:19 +0000 (10:55 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Sun, 13 Jun 2021 05:50:15 +0000 (05:50 +0000)
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>

src/cmd/compile/internal/walk/walk.go
test/fixedbugs/issue46720.go [new file with mode: 0644]

index fe2c62cd4f8ec1480dfc696eeb63cf597c72972a..26da6e314574431ef88187128097d4c644f00c1d 100644 (file)
@@ -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
diff --git a/test/fixedbugs/issue46720.go b/test/fixedbugs/issue46720.go
new file mode 100644 (file)
index 0000000..3b0151a
--- /dev/null
@@ -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) {}