You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has already been fixed on tip by cl 174704. For example:
$ gotip version
go version devel +a0262b201f Sat Nov 9 05:51:04 2019 +0000 linux/amd64
$ cat test.go
package p
func digit16(i uint16) byte {
if i < 10 {
return "0123456789"[i]
}
return '?'
}
The change will be included in Go1.14, so I'm closing this issue, since I don't think there is anything else to do here. Feel free to comment if you disagree.
What version of Go are you using (
go version
)?go version go1.13.1 windows/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
The generated code for all these variants is pretty much the same.
None of them calls
runtime.panicIndex
.What did you see instead?
The variants for
uint8
,uint16
anduint32
add unnecessary code for index checking.For example:
This is not restricted to amd64. On arm and 386, the comparison is executed redundantly:
The text was updated successfully, but these errors were encountered: