Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
npillmayer opened this issue Dec 26, 2021 · 6 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@npillmayer
Copy link

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
	}
}
@randall77
Copy link
Contributor

Indeed. Interested in sending a CL?

@adonovan @RaduBerinde

@randall77 randall77 added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 26, 2021
@randall77 randall77 added this to the Unplanned milestone Dec 26, 2021
@randall77 randall77 changed the title container/intsets.UnionWith: wrong return value in case of x ⊂ s x/tools/container/intsets: UnionWith wrong return value in case of x ⊂ s Dec 26, 2021
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Dec 26, 2021
@adonovan
Copy link
Member

Thanks for the bug report! Fix pending in https://go-review.googlesource.com/c/tools/+/374455 .

@gopherbot
Copy link

Change https://golang.org/cl/374455 mentions this issue: container/intsets: fix bug in UnionWith 'changed' result

@npillmayer
Copy link
Author

Now that was quick!
Sorry for not following closely. What's a "CL" by the way?
Thanks and all the best,
--Norbert

@ALTree
Copy link
Member

ALTree commented Dec 28, 2021

@npillmayer "Change List" as in https://en.wikipedia.org/wiki/Change_List. But Alan already sent one fixing the issue (linked above).

@adonovan
Copy link
Member

CL or Changelist is Perforce (and hence Googler) terminology for a change to a set of files under version control. The rest of the world seems to use the term PR, which is a GitHub concept.

@golang golang locked and limited conversation to collaborators Dec 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants