-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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: bogus warning "control reaches end of non-void function" #22767
Comments
By the way, this bogus warning spamed my terminal while GCC building system was compiling Go standard library with newly built gccgo. And even func foo(x int) int {
panic("not implemented")
} could trigger this. |
With |
Thanks, I have seen this too. Seems to be an annoying change in the GCC middle-end. Since the Go frontend provides its own "missing return" warning anyhow, the simplest approach may be for the frontend to disable the middle-end warning. |
Change https://golang.org/cl/80416 mentions this issue: |
GCC has started emitting "control reaches end of non-void function" warnings. Avoid them for Go by 1) marking the builtin function panic and the compiler-generated function __go_runtime_error as not returning and 2) adding a default case to the switch used for select statements that simply calls __builtin_unreachable. Fixes golang/go#22767 Reviewed-on: https://go-review.googlesource.com/80416 * go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_unreachable. (Gcc_backend::function): Add does_not_return parameter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255346 138bc75d-0d04-0410-961f-82ee72b054a4
GCC has started emitting "control reaches end of non-void function" warnings. Avoid them for Go by 1) marking the builtin function panic and the compiler-generated function __go_runtime_error as not returning and 2) adding a default case to the switch used for select statements that simply calls __builtin_unreachable. Fixes golang/go#22767 Reviewed-on: https://go-review.googlesource.com/80416 * go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_unreachable. (Gcc_backend::function): Add does_not_return parameter. From-SVN: r255346
What version of Go are you using (
go version
)?go version go1.9 gccgo (GCC) 8.0.0 20171114 (experimental) linux/amd64
Does this issue reproduce with the latest release?
Yes. This is gccgo in gcc trunk.
What operating system and processor architecture are you using (
go env
)?What did you do?
And build it with
LC_ALL=C go-8.0 build
.What did you expect to see?
No warnings and no errors.
What did you see instead?
I think panic() should have something like
__attribute__((noreturn))
in GNU C, to suppress the warning.The text was updated successfully, but these errors were encountered: