cmd/compile: some subsequent bounds checks are not eliminated #50365
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/eyem-XNTdye
https://go.godbolt.org/z/bMTGW9E7W
What did you expect to see?
Since
i
andsize
are always positive numbers,i*size+1
is not equal to zero and will be always greater thani*size
, socheck can be eliminated.
If
i*size+1
overflows ori*size+1 >= len(data)
,data[i*size+1]
will panic before accessingdata[i*size]
.What did you see instead?
Compiler emits two checks.
The text was updated successfully, but these errors were encountered: