Skip to content

FunC gives different results for operator ~% #1670

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

Open
jeshecdom opened this issue May 15, 2025 · 1 comment
Open

FunC gives different results for operator ~% #1670

jeshecdom opened this issue May 15, 2025 · 1 comment

Comments

@jeshecdom
Copy link

In the following code:

int calc(int x) {
    return ((x ~% -3) <= 0);
}

int calc3(int x, int y, int z) {
    return ((x ~% y) <= z);
}

calling calc(1) produces -1 (meaning true). But calling calc3(1,-3,0) produces 0 (meaning false).

Expected behavior

It was expected that calc(1) = calc3(1,-3,0), since calc is just a specialization of calc3.

@jeshecdom
Copy link
Author

The same happens with comparison operators: <=>, !=, and ==. The following expressions also produce differing results:

  • ((x ~% -3) <=> 1) in calc function, and ((x ~% y) <=> z) in cal3 function. We have calc(1) = -1, and calc3(1,-3,1) = 0.
  • ((x ~% -3) != 1) in calc function, and ((x ~% y) != z) in cal3 function. We have calc(1) = -1, and calc3(1,-3,1) = 0.
  • ((x ~% -3) == 1) in calc function, and ((x ~% y) == z) in cal3 function. We have calc(1) = 0, and calc3(1,-3,1) = -1.

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

No branches or pull requests

1 participant