You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\DEVPATH\GOBIN
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\DEVPATH\GOMOD
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\DEVPATH\GOPATH
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=E:\DEVELOPMENT\GO
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=E:\DEVELOPMENT\GO\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=D:\DEVPATH\GOPATH\src\playground\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build673745918=/tmp/go-build -gno-record-gcc-switches
Go does not have casts -- people may occasionally say "cast" when they are speaking informally but there is no notion of casting in Go.
Your example is a conversion, making a copy of its value and giving it a new type.
Your example uses the unsafe package, when you use that package the protections of the language are disabled
As such, you've created a bool value with a bit pattern of 0b00000010, that doesn't match the other bit pattern, 0b00000001 so the comparison is false.
Without using unsafe the compiler is free to assume that all true booleans have one representation and all false booleans have another. The spec doesn't define what they are so you cannot reliably create a bool using unsafe.Pointer conversions. If you want to create a boolean, this is the correct approach
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
)?go env
OutputWhat did you do?
What did you expect to see?
true
What did you see instead?
false
The text was updated successfully, but these errors were encountered: