Go version

go version go1.22.5 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/weeyoung/Library/Caches/go-build'
GOENV='/Users/weeyoung/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/weeyoung/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/weeyoung/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/local/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/local/lib/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='/usr/bin/clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/weeyoung/Documents/projs/go_samples/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/gp/y_s49k7d0ks8vcy38kpltrg40000gn/T/go-build1084406235=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

https://go.dev/play/p/nt37zxXTC3w

What did you see happen?

Pointer comparison results are not the same after pointer print statements

    a := struct{}{}
    b := struct{}{}
    fmt.Printf("%p\n", &a)
    fmt.Printf("%p\n", &b)
    // the following produces true
    // however commenting one or all of the print statement above makes it false
    // it does not matter if the comparison is before or after the print statements of pointers
    fmt.Println(&a == &b)

What did you expect to see?

fmt.Println(&a == &b) should always produce false, the print statements should not affect its result.

Comment From: gabyhelp

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: lwyw

closing issue since it's expected

Comment From: ianlancetaylor

https://go.dev/doc/faq#zero_size_types