Skip to content
New issue

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

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

Already on GitHub? # to your account

Do unsigned remainder on unsigned types #1211

Open
axch opened this issue Feb 5, 2023 · 1 comment
Open

Do unsigned remainder on unsigned types #1211

axch opened this issue Feb 5, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@axch
Copy link
Collaborator

axch commented Feb 5, 2023

Manifestation:

big = 2147483647
rem (big + 1) big
> 4294967295

Expected the answer to be 1.

(Note that big + 1 doesn't overflow the underlying Word32 -- it's just the rem operation messing up).

The cause is

IRem -> emitInstr (typeOf x) $ L.SRem x y []
, which unconditionally emits a signed remainder instruction, regardless of whether the Dex type is meant to be signed or unsigned.

@axch axch added bug Something isn't working good first issue Good for newcomers labels Feb 5, 2023
@axch
Copy link
Collaborator Author

axch commented Feb 5, 2023

By inspection, I expect IDiv to have the same problem.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant