]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix missing walk pass for static initialization slice
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 8 Oct 2022 05:32:06 +0000 (12:32 +0700)
committerGopher Robot <gobot@golang.org>
Mon, 10 Oct 2022 21:39:15 +0000 (21:39 +0000)
CL 403995 fixed static init of literal contains dynamic exprs, by
ensuring their init are ordered properly. However, we still need to walk
the generated init codes before appending to parent init. Otherwise,
codes that requires desugaring will be unhandled, causing the compiler
backend crashing.

Fixes #56105

Change-Id: Ic25fd4017473f5412c8e960a91467797a234edfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/440455
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/walk/complit.go
test/fixedbugs/issue56105.go [new file with mode: 0644]

index ce7b731ca6d3c296951e1296b526e24779aa8486..0c5ba97e4ae3863ae1a35ece95f4f32ad1ac3a3b 100644 (file)
@@ -243,6 +243,7 @@ func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node,
                                        // confuses about variables lifetime. So making sure those expressions
                                        // are ordered correctly here. See issue #52673.
                                        orderBlock(&sinit, map[string][]*ir.Name{})
+                                       walkStmtList(sinit)
                                }
                                init.Append(sinit...)
                                continue
diff --git a/test/fixedbugs/issue56105.go b/test/fixedbugs/issue56105.go
new file mode 100644 (file)
index 0000000..ecbe265
--- /dev/null
@@ -0,0 +1,11 @@
+// compile -d=libfuzzer
+
+// Copyright 2022 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() {
+       _ = [...][]int{{}, {}, {}, {}, {}}
+}