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
odeke-em
changed the title
"slice bounds out of range" not reported
cmd/compile: missing "slice bounds out of range" runtime panic unless variable is printed
Nov 19, 2018
odeke-em
changed the title
cmd/compile: missing "slice bounds out of range" runtime panic unless variable is printed
cmd/compile: missing "slice bounds out of range" runtime panic for stringtobytes of size <32 unless variable escapes
Nov 19, 2018
odeke-em
changed the title
cmd/compile: missing "slice bounds out of range" runtime panic for stringtobytes of size <32 unless variable escapes
cmd/compile: missing "slice bounds out of range" runtime panic for stringtobytes conversion of size <=32 unless variable escapes
Nov 19, 2018
I do not think there is a spec violation, there is no guarantee how large the slice capacity for "key" will be after the conversion as long as the string content fits. Similar other closed recent issue about this #28817.
Closing as Working As Intended as slice capacities can be effected by various optimization decisions that operate within the language specification. #24163 is still open to have an explicit mention that no capacity is guaranteed in the spec.
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
)?Linux, Windows, macOS
What did you do?
https://play.golang.org/p/npT2x8ieAV4
What did you expect to see?
panic: runtime error: slice bounds out of range
What did you see instead?
No panic
Panic only happens if you uncomment last Println
The text was updated successfully, but these errors were encountered: