Commit 332b24a
authored
[6.1][stdlib] Fix recoverable [U]Int128 division-by-zero (swiftlang#78045)
* Fix recoverable [U]Int128 division-by-zero
This patch fixes the division-by-zero case in the following methods:
- `Int128/dividedReportingOverflow(by:)`
- `Int128/remainderReportingOverflow(dividingBy:)`
- `UInt128/dividedReportingOverflow(by:)`
- `UInt128/remainderReportingOverflow(dividingBy:)`
* Add preconditions to trapping [U]Int128 division methods.
* Make consistent use of `_slowPath(_:)`.
Jumping on the `_slowPath(_:)` bandwagon like all other integer types.
* Copy existing UInt128 division comments to division operators.
* Add a comment about signed remainder overflow semantics as requested.
I have paraphrased @stephentyrone's and @xwu's review comments to the best of my ability.1 parent 7c59fa6 commit 332b24a
2 files changed
+48
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
302 | 306 | | |
303 | 307 | | |
304 | 308 | | |
| |||
307 | 311 | | |
308 | 312 | | |
309 | 313 | | |
310 | | - | |
311 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
312 | 323 | | |
313 | 324 | | |
314 | 325 | | |
| |||
366 | 377 | | |
367 | 378 | | |
368 | 379 | | |
369 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
370 | 387 | | |
371 | 388 | | |
372 | 389 | | |
| |||
378 | 395 | | |
379 | 396 | | |
380 | 397 | | |
381 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
382 | 408 | | |
383 | 409 | | |
384 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| |||
290 | 292 | | |
291 | 293 | | |
292 | 294 | | |
293 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
| |||
349 | 353 | | |
350 | 354 | | |
351 | 355 | | |
352 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
353 | 361 | | |
354 | 362 | | |
355 | 363 | | |
| |||
361 | 369 | | |
362 | 370 | | |
363 | 371 | | |
364 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
365 | 377 | | |
366 | 378 | | |
367 | 379 | | |
| |||
0 commit comments