Source file
test/fixedbugs/issue81863.go
1
2
3
4
5
6
7 package main
8
9
10 func f(c bool) int {
11 var x, y int
12 p := &x
13 if c {
14 p = &y
15 }
16 *p = 1
17 return x
18 }
19
20
21 func g(c bool) int {
22 var x, y int
23 p := &y
24 if c {
25 p = &x
26 }
27 *p = 1
28 return x
29 }
30
31 func main() {
32 if got := f(false); got != 1 {
33 panic(got)
34 }
35 if got := f(true); got != 0 {
36 panic(got)
37 }
38 if got := g(false); got != 0 {
39 panic(got)
40 }
41 if got := g(true); got != 1 {
42 panic(got)
43 }
44 }
45
View as plain text