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
Closed

Overflow checking for unary operators #1636

robinsierra opened this issue Oct 11, 2019 · 3 comments · Fixed by #1638
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@robinsierra
Copy link

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
Copy link
Member

Good catch!

@fubuloubu fubuloubu added the bug Bug that shouldn't change language semantics when fixed. label Oct 13, 2019
@robinsierra
Copy link
Author

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
Copy link
Member

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: vyperlang#1636
fubuloubu added a commit to fubuloubu/vyper that referenced this issue Oct 17, 2019
- Also rejects unary sub on unsigned integers

fixes: vyperlang#1636
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants