encoding/xml: unmarshaling empty xml val into non-zero struct has inconsistent behavior #19855
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +f8b0231639 Mon Mar 20 20:54:19 2017 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/shadams/go"
GORACE=""
GOROOT="/usr/local/google/home/shadams/dev/go"
GOTOOLDIR="/usr/local/google/home/shadams/dev/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build400923614=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
int (0) vs struct ({0})
What did you see instead?
int (0) vs struct ({2})
An empty xml val always results in a zero-valued destination, regardless of any pre-populated values, except if type is struct, ptr to struct, slice of struct, etc.
This was existing behavior before https://go-review.googlesource.com/c/38386/. Not sure if it makes sense to change at all, but wanted to document the inconsistency.
cc @rsc @bradfitz @ianlancetaylor
The text was updated successfully, but these errors were encountered: