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

fix: spurious unsigned overflows #590

Merged
merged 4 commits into from
Dec 3, 2023

Conversation

eightfilms
Copy link
Contributor

@eightfilms eightfilms commented Nov 29, 2023

Fixes #581

We add signedness checks prior to doing an errOverflow, + add tests (i've also confirmed that 0x80000000 * 2 erroneously triggers an overflow warning).

Given this source:

If one operand is unsigned int and the other is int, the operator treats them both as unsigned.

It seems like it might be fair to check that both LHS and RHS are not unsigned, in order for the overflow warning to show.

@ehaas re: your suggestion to look at fn add() in Value.zig, it seems like enumerations and ++ also relies on that - so I did these checks up one level instead, if this is fair?

src/aro/Parser.zig Outdated Show resolved Hide resolved
src/aro/Parser.zig Outdated Show resolved Hide resolved
@Vexu
Copy link
Owner

Vexu commented Nov 30, 2023

Can you add the check for subtraction and division as well?

@eightfilms eightfilms changed the title fix: spurious unsigned add and mul overflows fix: spurious unsigned overflows Nov 30, 2023
@eightfilms eightfilms requested a review from Vexu December 1, 2023 01:19
@Vexu Vexu merged commit a11ab45 into Vexu:master Dec 3, 2023
3 checks passed
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.

Spurious overflow warning for unsigned arithmetic
2 participants