What version of Go are you using (go version)?
$ go version
go version go1.18.1 darwin/amd64
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
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOOS="darwin"
GOPROXY="https://goproxy.cn"
GOROOT="/usr/local/Cellar/go/1.18.1/libexec"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.18.1/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2b/d9_jv6cs1bl2dqqblnzq4_8c0000gp/T/go-build2756878695=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Given var s1 struct{} and var s2 struct{}, the result of &s1 == &s2 is inconsistent:
the following snippet yielding false:
package main
import (
"fmt"
)
func main() {
var s1 struct{}
var s2 struct{}
fmt.Println(&s1 == &s2) // false
}
while this snippet yielding true:
package main
import (
"fmt"
"unsafe"
)
func main() {
var s1 struct{}
var s2 struct{}
fmt.Println(unsafe.Pointer(&s1), unsafe.Pointer(&s2))
fmt.Println(&s1 == &s2) // true
}
What did you expect to see?
The results in two circumstances should be the same. Both of them should be true.
What did you see instead?
They are not. Quite confusing for newbies.
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 envOutputWhat did you do?
Given
var s1 struct{}andvar s2 struct{}, the result of&s1 == &s2is inconsistent:the following snippet yielding
false:while this snippet yielding
true:What did you expect to see?
The results in two circumstances should be the same. Both of them should be
true.What did you see instead?
They are not. Quite confusing for newbies.