blob: b2f69dbfa419991a64848924ecbd0fd2b9804270 [file] [log] [blame]
Russ Cox1b3244e2012-12-22 16:46:01 -05001// run
2
3// Copyright 2012 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// Order of operations in select.
8
9package main
10
11func main() {
12 c := make(chan int, 1)
13 x := 0
14 select {
15 case c <- x: // should see x = 0, not x = 42 (after makec)
16 case <-makec(&x): // should be evaluated only after c and x on previous line
17 }
18 y := <-c
19 if y != 0 {
20 panic(y)
21 }
22}
23
24func makec(px *int) chan bool {
25 if false { for {} }
26 *px = 42
27 return make(chan bool, 0)
28}