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

cmd/compile: `switch` statement on a custom `int32` type with negative values behaves differently in two consecutive calls [1.12 backport] #32583

Closed
gopherbot opened this issue Jun 12, 2019 · 3 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 12, 2019

@josharian requested issue #32560 to be considered for backport to the next 1.12 minor release.

@gopherbot please open backport issues. This is an important compiler correctness bug with a safe, localized, minimal fix.

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Jun 12, 2019

Change https://golang.org/cl/181978 mentions this issue: [release-branch.go1.12] cmd/compile: fix range analysis of small signed integers

@katiehockman

This comment has been minimized.

Copy link
Member

@katiehockman katiehockman commented Jun 17, 2019

Approving this cherry-pick since it is a localized, small risk change with no workaround.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Jul 1, 2019

Fixed by CL 181978 / 39b533e.

@rsc rsc closed this Jul 1, 2019
gopherbot pushed a commit that referenced this issue Jul 1, 2019
…ed integers

For int8, int16, and int32, comparing their unsigned value to MaxInt64
to determine non-negativity doesn't make sense, because they have
negative values whose unsigned representation is smaller than that.
Fix is simply to compare with the appropriate upper bound based on the
value type's size.

Fixes #32583.

Change-Id: Ie7afad7a56af92bd890ba5ff33c86d1df06cfd9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/181797
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit f44404e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/181978
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.