aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-09-08 08:41:54 -0700
committerHeschi Kreinick <heschi@google.com>2021-11-24 19:38:31 +0000
commit4eaf0b7a58d024e7d44f58a26914fb1885fd4dd6 (patch)
tree4fd279e9a874f5b408e10fe0530ee45bce6ee42f /test
parent4536558f160d147224b07c1167c1b4750b3fcca8 (diff)
downloadgo-4eaf0b7a58d024e7d44f58a26914fb1885fd4dd6.tar.gz
go-4eaf0b7a58d024e7d44f58a26914fb1885fd4dd6.zip
[release-branch.go1.17] cmd/compile: fix case where init info of OAS node is dropped
When an OAS node is converted to an OSELRECV2 node in tcSelect(), the possible DCL node in the Init field was being dropped, since a completely new node was being created and the Init field was not set. I don't expect n.Init() to be set for the ORECV case, but the code now deals with that too. Fixed bug in both tcSelect() and transformSelect(). Cherry-picked from https://go-review.googlesource.com/c/go/+/348569 Fixes #49511 Change-Id: Id5b736daa8e90afda88aaa3769dde801db294c0d Reviewed-on: https://go-review.googlesource.com/c/go/+/363664 Trust: Dan Scales <danscales@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue48289.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/fixedbugs/issue48289.go b/test/fixedbugs/issue48289.go
new file mode 100644
index 0000000000..94dbeee34c
--- /dev/null
+++ b/test/fixedbugs/issue48289.go
@@ -0,0 +1,28 @@
+// run
+
+// 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 main
+
+import "fmt"
+
+func main() {
+ ch := make(chan int, 1)
+
+ var ptrs [2]*int
+ for i := range ptrs {
+ ch <- i
+ select {
+ case x := <-ch:
+ ptrs[i] = &x
+ }
+ }
+
+ for i, ptr := range ptrs {
+ if *ptr != i {
+ panic(fmt.Sprintf("got *ptr %d, want %d", *ptr, i))
+ }
+ }
+}