Closed as not planned
Description
Go version
go1.22.1
Output of go env
in your module/workspace:
GO111MODULE='on'
GOARCH='amd64'
GOBIN='/Users/leo/go/bin'
GOCACHE='/Users/leo/Library/Caches/go-build'
GOENV='/Users/leo/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/leo/go/pkg/mod'
GONOPROXY='*.byted.org,*.everphoto.cn,git.smartisan.com'
GONOSUMDB='*.byted.org,*.everphoto.cn,git.smartisan.com'
GOOS='darwin'
GOPATH='/Users/leo/go'
GOPRIVATE='*.byted.org,*.everphoto.cn,git.smartisan.com'
What did you do?
func main() {
l := []int{1, 2, 3}
for i, v := range l {
println(&i, &v)
}
}
result is:
0xc00004c718 0xc00004c710
0xc00004c718 0xc00004c710
0xc00004c718 0xc00004c710
func main() {
l := []int{1, 2, 3}
for i, v := range l {
fmt.Println(&i, &v)
}
}
result is:
0xc000096010 0xc000096008
0xc000096030 0xc000096018
0xc000096040 0xc000096038
func main() {
l := []int{1, 2, 3}
for i, v := range l {
println(&i, &v)
fmt.Println(&i, &v)
}
}
result is:
0xc0000120a0 0xc000012098
0xc0000120a0 0xc000012098
0xc0000120c0 0xc0000120a8
0xc0000120c0 0xc0000120a8
0xc0000120d0 0xc0000120c8
0xc0000120d0 0xc0000120c8
What did you see happen?
result is different between with println(&i, &v) & fmt.Println(&i, &v)
What did you expect to see?
0xc000096010 0xc000096008
0xc000096030 0xc000096018
0xc000096040 0xc000096038