]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: mark negative size memclr non-inlineable
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 22 Mar 2023 10:45:07 +0000 (17:45 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 22 Mar 2023 16:43:10 +0000 (16:43 +0000)
Fixes #59174

Change-Id: I72b2b068830b90d42a0186addd004fb3175b9126
Reviewed-on: https://go-review.googlesource.com/c/go/+/478375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/ssa/rewrite.go
test/fixedbugs/issue59174.go [new file with mode: 0644]

index 54ea2d3f4f7a1e00eff3059a65176e1d00dc59fb..afd56018d35cfb0ee67592e43c2be9dc63502427 100644 (file)
@@ -1370,6 +1370,9 @@ func zeroUpper56Bits(x *Value, depth int) bool {
 }
 
 func isInlinableMemclr(c *Config, sz int64) bool {
+       if sz < 0 {
+               return false
+       }
        // TODO: expand this check to allow other architectures
        // see CL 454255 and issue 56997
        switch c.arch {
diff --git a/test/fixedbugs/issue59174.go b/test/fixedbugs/issue59174.go
new file mode 100644 (file)
index 0000000..33a19a4
--- /dev/null
@@ -0,0 +1,12 @@
+// compile
+
+// 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 p
+
+func p() {
+       s := make([]int, copy([]byte{' '}, "")-1)
+       _ = append([]int{}, make([]int, len(s))...)
+}