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

Intermediate overflows are in some situations allowed #7240

Open
TomAFrench opened this issue Jan 30, 2025 · 0 comments
Open

Intermediate overflows are in some situations allowed #7240

TomAFrench opened this issue Jan 30, 2025 · 0 comments

Comments

@TomAFrench
Copy link
Member

There's a number of cases where due to simplifications on operations such as x^x or x-x we allow intermediate overflows.

This came up recently in #7189 where the program below started to pass due to being able to simplify var1 to 0 and then removing all the overflows through dead instruction elimination.

#[test(should_fail_with = "attempt to add with overflow")]
fn main() {
    let var1: u8 = ((255 + 1) ^ (255 + 1)) - ((255 + 1) - (255 + 1));
    assert_eq(var1, 0);
}

We should pay attention to whether we want to perform dead instruction elimination in these cases or if we should preserve the addition/subtractions at least to maintain checked arithmetic.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jan 30, 2025
@TomAFrench TomAFrench changed the title Intermediate overflows are in some situations Intermediate overflows are in some situations allowed Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant