We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
go version go1.11 darwin/amd64
Yes
go env
GOARCH="amd64" GOBIN="" GOCACHE="/Users/jack/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/jack/Development/Go" GOPROXY="" GORACE="" GOROOT="/usr/local/Cellar/go/1.11/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/67/bwpvphcn1kx4xjjzhvxtt6yw0000gn/T/go-build917588304=/tmp/go-build -gno-record-gcc-switches -fno-common"
Tried running the following code;
package main import "fmt" func main() { fmt.Printf("value: %d\n", int8(byte(200))) }
value: -56
./main.go:6:30: constant 200 overflows int8
The following code seems to work fine, so there's something odd going on when using a constant value in byte(...);
byte(...)
package main import "fmt" func main() { i := 200 fmt.Printf("value: %d\n", int8(byte(i))) }
The text was updated successfully, but these errors were encountered:
It works correctly. This behavior is defined in the language specification.
Sorry, something went wrong.
yes, it is well defined. Overflows are allowed at run time, but not at compile time.O
See https://blog.golang.org/constants
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Tried running the following code;
What did you expect to see?
What did you see instead?
The following code seems to work fine, so there's something odd going on when using a constant value in
byte(...)
;The text was updated successfully, but these errors were encountered: