Commit 72d62ec
authored
Fix overflow in type cast for GUPS benchmark (#58)
* Fix overflow in type cast for GUPS benchmark
Changed size_t n = (size_t)(1 << logn) to size_t n = ((size_t)1) << logn
to prevent integer overflow when logn >= 31. The original code would
perform the left shift on an int (1) before casting to size_t, causing
overflow. Now the cast happens first, allowing proper handling of large
values like n = 2^31.
Fixes #571 parent 52b16fa commit 72d62ec
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
462 | | - | |
| 461 | + | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
| 599 | + | |
0 commit comments