Skip to content

reflect: Zero() changes behavior in Go1.16rc1 #43986

@koron

Description

@koron

What version of Go are you using (go version)?

$ go version
go version go1.16rc1 windows/amd64

Does this issue reproduce with the latest release?

no. it reprocude with latest release candidate

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\koron\AppData\Local\go-build
set GOENV=C:\Users\koron\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\koron\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\koron\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Local\Go\current
set GOSUMDB=sum.golang.org
set GOTMPDIR=C:\Users\koron\go\tmp
set GOTOOLDIR=C:\Local\Go\current\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16rc1
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\koron\go\tmp\go-build183394138=/tmp/go-build -gno-record-gcc-switches

What did you do?

Run this program with Go 1.16rc1 and 1.15.7

package main

import "reflect"

func main() {
	s := ""
	go116 := reflect.DeepEqual(reflect.Zero(reflect.TypeOf(s)), reflect.ValueOf(s))
	if go116 {
		println("I am Go 1.16 gopher!")
	} else {
		println("I am Go 1.15 or below gopher!")
	}
}

You can get it from https://play.golang.org/p/0tzp7aZhnQ8

What did you expect to see?

reflect.DeepEqual(reflect.Zero(reflect.TypeOf(s)), reflect.ValueOf(s)) returns false for both Go 1.16rc1 and Go 1.15.7

What did you see instead?

Go 1.15.7 returns false, but Go 1.16rc1 returns true

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions