Vyper: Overflow checking for unary operators

Created on 11 Oct 2019  路  3Comments  路  Source: vyperlang/vyper

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.

bug

All 3 comments

Good catch!

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

should not be allowed, yes

Was this page helpful?
0 / 5 - 0 ratings