Commit 39b533ed authored by Matthew Dempsky's avatar Matthew Dempsky Committed by Russ Cox
Browse files

[release-branch.go1.12] cmd/compile: fix range analysis of small signed 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: default avatarJosh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarDavid Chase <drchase@google.com>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit f44404eb)
Reviewed-on: https://go-review.googlesource.com/c/go/+/181978


Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
parent 77c14d29
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment