-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
gccgo: does not detect missing return #11591
Comments
This is happening because Gogo::add_label_definition just returns if the label name is "_". |
Hmm, I'm missing some subtlety here. The reason why this program isn't rejected is because f is treated as if it were defined as |
The rule in the spec is that it's OK to omit a return statement if the last statement in the function is a terminating statement. "for{}" is a terminating statement--execution will never proceed past that point. "_:" is not a terminating statement--it's a label, and in principle somebody might goto that label, even though obviously that can't happen in this case. Does that answer the question? |
@paranoiacblack It's a "Labeled Statement" where the statement is the empty statement. So there's actually a non-terminating (empty statement) at the end. |
CL https://golang.org/cl/12043 mentions this issue. |
Fixes golang/go#11591. Reviewed-on: https://go-review.googlesource.com/12043 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226009 138bc75d-0d04-0410-961f-82ee72b054a4
Fixes golang/go#11591. Reviewed-on: https://go-review.googlesource.com/12043 From-SVN: r226009
gccgo successfully compiles the following program:
while both gc and go/types reject it with
missing return
.gcc version 6.0.0 2015070 (experimental) (GCC)
The text was updated successfully, but these errors were encountered: