Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ssa select case call expr order #48

Open
visualfc opened this issue Apr 3, 2022 · 0 comments
Open

bug: ssa select case call expr order #48

visualfc opened this issue Apr 3, 2022 · 0 comments

Comments

@visualfc
Copy link
Member

visualfc commented Apr 3, 2022

$GOROOT/test/chan/select5

bug: golang.org/x/tools/go/ssa build order fp, fc

package main

var c = make(chan int, 1)
var nilch chan int
var n = 1
var x int
var i interface{}
var dummy = make(chan int)
var m = make(map[int]int)
var order = 0

// check order of operations by ensuring that
// successive calls to checkorder have increasing o values.
func checkorder(o int) {
	if o <= order {
		println("invalid order", o, "after", order)
		panic("order")
	}
	order = o
}

func fc(c chan int, o int) chan int {
	checkorder(o)
	return c
}

func fp(p *int, o int) *int {
	checkorder(o)
	return p
}

func init() {
	order = 0
	c <- n
	select {
	case *fp(&x, 100) = <-fc(c, 1):
	}
	if x != n {
		die(x)
	}
	n++
}

func die(x int) {
	println("have", x, "want", n)
	panic("chan")
}

func main() {
}
func init#1():
0:                                                                entry P:0 S:2
	*order = 0:int
	t0 = *c                                                        chan int
	t1 = *n                                                             int
	send t0 <- t1
	t2 = fp(x, 100:int)                                                *int
	t3 = *c                                                        chan int
	t4 = fc(t3, 1:int)                                             chan int
	t5 = <-t4                                                           int
	*t2 = t5
	t6 = *x                                                             int
	t7 = *n                                                             int
	t8 = t6 != t7                                                      bool
	if t8 goto 1 else 2
1:                                                              if.then P:1 S:1
	t9 = *x                                                             int
	t10 = die(t9)                                                        ()
	jump 2
2:                                                              if.done P:2 S:0
	t11 = *n                                                            int
	t12 = t11 + 1:int                                                   int
	*n = t12
	return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant