]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: allow ir.OMIN/ir.OMAX in mayCall
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 3 Jun 2023 01:33:51 +0000 (08:33 +0700)
committerGopher Robot <gobot@golang.org>
Mon, 5 Jun 2023 03:11:36 +0000 (03:11 +0000)
CL 496257 adds min/max builtins, which may appear as argument to a
function call, so it will be tested by mayCall. But those ops are not
handled by mayCall, causes the compiler crashes.

Fixes #60582

Change-Id: I729f10bf62b4aad39ffcb1433f576e74d09fdd9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/500575
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

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

index f5a2f9b9ac340cb908ee4f9e98068b1490706a3d..265066200c6f8441831dfb6b8fbbc575d227bb9a 100644 (file)
@@ -340,7 +340,7 @@ func mayCall(n ir.Node) bool {
                case ir.OLITERAL, ir.ONIL, ir.ONAME, ir.OLINKSYMOFFSET, ir.OMETHEXPR,
                        ir.OAND, ir.OANDNOT, ir.OLSH, ir.OOR, ir.ORSH, ir.OXOR, ir.OCOMPLEX, ir.OEFACE,
                        ir.OADDR, ir.OBITNOT, ir.ONOT, ir.OPLUS,
-                       ir.OCAP, ir.OIMAG, ir.OLEN, ir.OREAL,
+                       ir.OCAP, ir.OIMAG, ir.OLEN, ir.OREAL, ir.OMIN, ir.OMAX,
                        ir.OCONVNOP, ir.ODOT,
                        ir.OCFUNC, ir.OIDATA, ir.OITAB, ir.OSPTR,
                        ir.OBYTES2STRTMP, ir.OGETG, ir.OGETCALLERPC, ir.OGETCALLERSP, ir.OSLICEHEADER, ir.OSTRINGHEADER:
diff --git a/test/fixedbugs/issue60582.go b/test/fixedbugs/issue60582.go
new file mode 100644 (file)
index 0000000..f698918
--- /dev/null
@@ -0,0 +1,15 @@
+// build
+
+// Copyright 2023 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 main
+
+import "fmt"
+
+func main() {
+       a, b := 5, 7
+       fmt.Println(min(a, b))
+       fmt.Println(max(a, b))
+}