Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let iN overflow #2104

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Let iN overflow #2104

merged 1 commit into from
Jan 21, 2025

Conversation

plajjan
Copy link
Contributor

@plajjan plajjan commented Jan 20, 2025

Our signed integer types are now allowed to overflow. We use the straight C types and in the C specification, signed integer overflow is undefined behavior. Most C compilers are quite lax and don't enforce it in any way per default. We use Zig to compile and per default it enables all sorts of UBsan, and so we have inherited that behavior.

However, in Acton we think the sane behavior is for integer operations to be well defined and not change with compilation flags, plus we want decent performance and so overflow is the most sane behavior. That is now the case!

Some simple test cases are added to verify overflow works. u16 / i16 does not work, likely since the underpinning type is actually not 16 bits.

Fixes #2079

Our signed integer types are now allowed to overflow. We use the straight
C types and in the C specification, signed integer overflow is undefined
behavior. Most C compilers are quite lax and don't enforce it in any
way per default. We use Zig to compile and per default it enables all
sorts of UBsan, and so we have inherited that behavior.

However, in Acton we think the sane behavior is for integer operations
to be well defined and not change with compilation flags, plus we want
decent performance and so overflow is the most sane behavior. That is
now the case!

Some simple test cases are added to verify overflow works. u16 / i16
does not work, likely since the underpinning type is actually not 16 bits.
@plajjan plajjan merged commit 02ce405 into main Jan 21, 2025
25 checks passed
@plajjan plajjan deleted the int-overflow branch January 21, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set -fno-sanitize=signed-integer-overflow
1 participant