fix(bitmap): handle INT32_MIN safely in LOCAL_ABS macro #143
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
OragonEfreet/banjo!143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/dib-int32-min-ub"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix undefined behavior when negating INT32_MIN by using unsigned
arithmetic instead. The old macro
(uint32_t)(-(x))would invokeUB when x is INT32_MIN because -INT32_MIN overflows int32_t.
The new approach casts to uint32_t first, then uses unsigned
subtraction:
(uint32_t)0 - (uint32_t)(x), which is well-defined.OragonEfreet referenced this pull request2026-06-03 20:42:42 +02:00