From: nimelehin Date: Mon, 11 Apr 2022 16:54:30 +0000 (+0300) Subject: cmd/compile: fix compilation crash with several blank labels X-Git-Tag: go1.19beta1~700 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=be0262a1279ab37ff2cae562de37afd333f5ada4;p=gostls13.git cmd/compile: fix compilation crash with several blank labels Fixes #52278 Change-Id: Ibf67c7b019feec277d316e04d93b458efea133fb Reviewed-on: https://go-review.googlesource.com/c/go/+/399574 Reviewed-by: Keith Randall Run-TryBot: Keith Randall Reviewed-by: Keith Randall Auto-Submit: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/compile/internal/escape/escape.go b/src/cmd/compile/internal/escape/escape.go index 4713ecddca..4408a531ec 100644 --- a/src/cmd/compile/internal/escape/escape.go +++ b/src/cmd/compile/internal/escape/escape.go @@ -210,6 +210,9 @@ func (b *batch) walkFunc(fn *ir.Func) { switch n.Op() { case ir.OLABEL: n := n.(*ir.LabelStmt) + if n.Label.IsBlank() { + break + } if e.labels == nil { e.labels = make(map[*types.Sym]labelState) } diff --git a/src/cmd/compile/internal/escape/stmt.go b/src/cmd/compile/internal/escape/stmt.go index 0afb5d64ef..4e8dd904ff 100644 --- a/src/cmd/compile/internal/escape/stmt.go +++ b/src/cmd/compile/internal/escape/stmt.go @@ -50,6 +50,9 @@ func (e *escape) stmt(n ir.Node) { case ir.OLABEL: n := n.(*ir.LabelStmt) + if n.Label.IsBlank() { + break + } switch e.labels[n.Label] { case nonlooping: if base.Flag.LowerM > 2 { diff --git a/test/fixedbugs/issue52278.go b/test/fixedbugs/issue52278.go new file mode 100644 index 0000000000..56169e6871 --- /dev/null +++ b/test/fixedbugs/issue52278.go @@ -0,0 +1,12 @@ +// compile + +// 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 main + +func main() { +_: +_: +}