compiler: support 64-bit numbers in bounds check

This commit is contained in:
Ayke van Laethem
2018-10-23 14:07:27 +02:00
parent 17e8c850f6
commit 96f74ec153
2 changed files with 30 additions and 5 deletions
+8
View File
@@ -29,6 +29,14 @@ func lookupBoundsCheck(length lenType, index int) {
}
}
// Check for bounds in *ssa.Index, *ssa.IndexAddr and *ssa.Lookup.
// Supports 64-bit indexes.
func lookupBoundsCheckLong(length lenType, index int64) {
if index < 0 || index >= int64(length) {
runtimePanic("index out of range")
}
}
// Check for bounds in *ssa.Slice.
func sliceBoundsCheck(length lenType, low, high uint) {
if !(0 <= low && low <= high && high <= uint(length)) {