-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone

Description
What version of Go are you using (go version
)?
$ go version go version go1.20.1 windows/amd64
Also tested: go1.21-f5c7416511
, go1.19
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= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\tdakkota\AppData\Local\go-build set GOENV=C:\Users\tdakkota\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\tdakkota\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\tdakkota\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=G:\scoop\apps\go\current set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=G:\scoop\apps\go\current\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.20.1 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=C:\Users\tdakkota\Desktop\tmp\go.mod set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -g set PKG_CONFIG=pkg-config
What did you do?
https://go.dev/play/p/KYZ1WC9j4VP
https://go.godbolt.org/z/1KMEo5nP8 (note: uses Go 1.19)
What did you expect to see?
Compiler should generate the same code for new(T)
and &T{}
.
What did you see instead?
new(T)
compiles to
MOVUPS X15, main..autotmp_1+8(SP)
but &T{}
compiles to
MOVUPS X15, main..autotmp_2+8(SP)
MOVUPS X15, main..autotmp_2+8(SP) // overwrite zeroed value with zero
Big structures like this
type T struct {
A, B, C, D, E int
}
are not affected.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.