Skip to content

Commit 0a82ef8

Browse files
authored
Re-add debug-mode overflow check in index(_:,_offsetBy:limit:)
1 parent a3fdcfa commit 0a82ef8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ extension Unsafe${Mutable}BufferPointer: ${Mutable}Collection, RandomAccessColle
221221
return nil
222222
}
223223

224-
// No need to check here, for the same index misuse reasons.
225-
return i &+ n
224+
let result = i.addingReportingOverflow(n)
225+
_debugPrecondition(!result.overflow)
226+
return result.partialValue
226227
}
227228

228229
@inlinable // unsafe-performance

0 commit comments

Comments
 (0)