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=
set GOARCH=amd64
set GOBIN=D:\GoFuture\bin
set GOCACHE=C:\Users\乐谱里的画\AppData\Local\go-build
set GOENV=C:\Users\乐谱里的画\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\GoFuture\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\GoFuture
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
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 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ 乐谱里~1\AppData\Local\Temp\go-build1467603294=/tmp/go-build -gno-record-gcc-switches
What did you do?
The results are different when struct A has only one field and B has two or above fields, and it just happens when parameter type is interface.
I'm not sure if that's a bug.
Please clear my doubts, tx!
package main
import (
"fmt"
)
funcmain() {
a:=A{}
m("A", a, SetAI(&a))
b:=B{}
m("B", b, SetBI(&b))
}
typeAstruct {
IintSstring
}
typeBstruct {
Iint
}
funcSetAI(a*A) A {
a.I=10return*a
}
funcSetBI(b*B) B {
b.I=10return*b
}
funcm(namestring, arg1, arg2interface{}) {
fmt.Println(name+":", arg1, arg2)
}
``` golang
### What did you expect to see?
A: {10} {10}
B: {10} {10}
### What did you see instead?
A: {0 } {10 }
B: {10} {10}
The text was updated successfully, but these errors were encountered:
In a function call like m("A", a, SetAI(&a)) the Go language does not specify whether the second argument or the third argument is evaluated first. This code could be equivalent to
t1:=at2:=SetAI(&a)
m("A", t1, t2)
or it could be equivalent to
t2:=SetAI(&s)
t1:=am("A", t1, t2)
Different compilers can produce different results. Even different versions of the same compiler can produce different results.
In general we do not use the issue tracker for questions. If you have further questions about Go please use a forum. See https://go.dev/wiki/Questions. Thanks.
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?
The results are different when struct A has only one field and B has two or above fields, and it just happens when parameter type is interface.
I'm not sure if that's a bug.
Please clear my doubts, tx!
The text was updated successfully, but these errors were encountered: