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

Modulo can't overflow #1687

Closed
Shungy opened this issue Feb 24, 2023 · 2 comments
Closed

Modulo can't overflow #1687

Shungy opened this issue Feb 24, 2023 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@Shungy
Copy link

Shungy commented Feb 24, 2023

BinaryType.MODULO,

Do we consider revert when modulo by zero as overflow? Since can_be_checked_for_overflow is never used internally this is not clear.

@0xalpharush
Copy link
Contributor

I believe modulo can be excluded based on https://blog.soliditylang.org/2020/12/16/solidity-v0.8.0-release-announcement/:

The following operations (including their compound assignment versions like +=) now have checks that they did not have before:

addition (+), subtraction (-), multiplication (*)
increment and decrement (++ / --)
unary negation (-)
exponentiation (**)
division (see below) (/)

Additionally, we are missing unary negation and should implement can_be_checked_for_overflow for unary as well.

MINUS_PRE = 8 # for stuff like uint(-1)

@0xalpharush 0xalpharush added the bug Something isn't working label Feb 24, 2023
@0xalpharush 0xalpharush added this to the 0.9.4 milestone Apr 4, 2023
@0xalpharush
Copy link
Contributor

We do not need to implement can_be_checked_for_overflow for unary negate because it is converted to a binary operation e.g. -7 -> 0 - 7 and subtraction is included in binop's can_be_checked_for_overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants