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 signed integer overflow in RV32M #35

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

visitorckw
Copy link
Contributor

The current implementation of the mul instruction does not guard against integer overflow, potentially leading to undefined behavior. Cast the operands to int64_t before performing the multiplication to ensure that the result can be accommodated without overflow. The lower 32 bits of the product are then extracted, preserving the correct uint32_t type.

The current implementation of the mul instruction does not guard
against integer overflow, potentially leading to undefined behavior.
Cast the operands to int64_t before performing the multiplication to
ensure that the result can be accommodated without overflow. The lower
32 bits of the product are then extracted, preserving the correct
uint32_t type.
@jserv jserv merged commit 90ddf1c into sysprog21:master Jan 8, 2024
2 checks passed
@jserv
Copy link
Collaborator

jserv commented Jan 8, 2024

Thank @visitorckw for contributing!

@visitorckw visitorckw deleted the fix-signed-integer-oveflow branch January 9, 2024 00:30
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.

2 participants