test/fixedbugs/issue48289.go
raw| 1 | // run |
| 2 | |
| 3 | // Copyright 2021 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | package main |
| 8 | |
| 9 | import "fmt" |
| 10 | |
| 11 | func main() { |
| 12 | ch := make(chan int, 1) |
| 13 | |
| 14 | var ptrs [2]*int |
| 15 | for i := range ptrs { |
| 16 | ch <- i |
| 17 | select { |
| 18 | case x := <-ch: |
| 19 | ptrs[i] = &x |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | for i, ptr := range ptrs { |
| 24 | if *ptr != i { |
| 25 | panic(fmt.Sprintf("got *ptr %d, want %d", *ptr, i)) |
| 26 | } |
| 27 | } |
| 28 | } |