Closed
Description
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
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xry111/go"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/usr/lib64/gcc/x86_64-pc-linux-gnu/8.0.0"
GCCGO="/usr/bin/gccgo-8.0"
CC="gcc-8.0"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build037067240=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
CXX="g++-8.0"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
package main
import (
"fmt"
"os"
)
func foo() int {
switch os.Args[0] {
case "cat":
return 0
case "ls":
return 1
}
panic("wtf")
}
func main() {
fmt.Println(foo())
}
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?
# hw
./main.go: In function 'main.foo':
go1: warning: control reaches end of non-void function [-Wreturn-type]
I think panic() should have something like __attribute__((noreturn))
in GNU C, to suppress the warning.