Skip to content

go.tools/ssa: Select's with > 1 case, but no default, generate unreachable block with an invalid Return #7022

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

Closed
axw opened this issue Dec 28, 2013 · 2 comments

Comments

@axw
Copy link
Contributor

axw commented Dec 28, 2013

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Save http://play.golang.org/p/Q7tUGUqD9k as select.go
2. ssadump -build=F select.go

What is the expected output?

That the SSA form for "func f() int" should not contain the final block; it is
not reachable, and it has an invalid Return statement (a bare Return, whereas the
function has >0 results).

What do you see instead?

func f() int:
.0.entry:                                                               P:0 S:2
    t0 = select blocking [<-nil:chan int, <-nil:chan int] (index int, ok bool, int, int)
    t1 = extract t0 #0                                                  int
    t2 = t1 == 0:int                                                   bool
    if t2 goto 1.select.body else 2.select.next
.1.select.body:                                                         P:1 S:0
    return 123:int
.2.select.next:                                                         P:1 S:2
    t3 = t1 == 1:int                                                   bool
    if t3 goto 3.select.body else 4.select.next
.3.select.body:                                                         P:1 S:0
    return 456:int
.4.select.next:                                                         P:1 S:0
    return

Which compiler are you using (5g, 6g, 8g, gccgo)?

N/A

Which operating system are you using?

N/A

Which version are you using?  (run 'go version')

N/A

Please provide any additional information below.

I don't care too much about the unreachable block, but the invalid Return makes my
client code uglier than it ought to be. For now I'll treat bare Returns in functions
with >0 results as being unreachable.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-tools.

Owner changed to @adonovan.

@adonovan
Copy link
Member

adonovan commented Jan 8, 2014

@axw axw added fixed labels Jan 8, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants