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

Overflow checking for unary operators #1636

Closed
robinsierra opened this issue Oct 11, 2019 · 3 comments · Fixed by #1638
Labels
bug

Comments

@robinsierra
Copy link

@robinsierra robinsierra commented Oct 11, 2019

Version Information

  • Vyper version: 0.1.0b13+commit.6385900

What's your issue about?

The unary negation operator does not check for overflows:

@public
def neg(i: int128) -> int128:
    return -i

This is OK for all inputs except -2^127, for which it returns -2^127 instead of reverting.

@fubuloubu

This comment has been minimized.

Copy link
Member

@fubuloubu fubuloubu commented Oct 13, 2019

Good catch!

@fubuloubu fubuloubu added the bug label Oct 13, 2019
@robinsierra

This comment has been minimized.

Copy link
Author

@robinsierra robinsierra commented Oct 17, 2019

Overflows also happen for uint256, although it is questionable whether using negation on an unsigned value should be allowed at all.

@fubuloubu

This comment has been minimized.

Copy link
Member

@fubuloubu fubuloubu commented Oct 17, 2019

should not be allowed, yes

fubuloubu added a commit to fubuloubu/vyper that referenced this issue Oct 17, 2019
- Also rejects unary sub on unsigned integers

fixes: ethereum#1636
fubuloubu added a commit to fubuloubu/vyper that referenced this issue Oct 17, 2019
- Also rejects unary sub on unsigned integers

fixes: ethereum#1636
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.