Skip to content

x/tools/container/intsets: UnionWith wrong return value in case of x ⊂ s #50352

@npillmayer

Description

@npillmayer

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

$ go version
go version go1.17.3 darwin/amd64

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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/npi/Library/Caches/go-build"
GOENV="/Users/npi/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/npi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/npi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.3/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/npi/prg/go/thirdparty/tools/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/9x/1db0p52x4kx642f9y26rgfpr0000gn/T/go-build429451647=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.17.3 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.17.3
uname -v: Darwin Kernel Version 19.6.0: Thu Sep 16 20:58:47 PDT 2021; root:xnu-6153.141.40.1~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H1419
lldb --version: lldb-1103.0.22.10
Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
gdb --version: GNU gdb (GDB) 11.1

What did you do?

With container/intsets, call

s.UnionWith(x)

with special case x ⊂ s
=> returns true

What did you expect to see?

Documentation of UnionWith states:
// UnionWith sets s to the union s ∪ x, and reports whether s grew.

However, with x ⊂ s; s won't change, and UnionWith therefore should return false.

What did you see instead?

s.UnionWith(x) returns true in case of x ⊂ s

File sparse.go, line 638ff should probably look something like this:

if sb.bits[i] != xb.bits[i] {
	w := sb.bits[i]
	sb.bits[i] |= xb.bits[i]
	if w != sb.bits[i] { // check for change; no change in case of x ⊂ s
		changed = true
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions