According to Solidity documentation:
Prior to Solidity 0.8.0, arithmetic operations would always wrap in case of under- or overflow leading to widespread use of libraries that introduce additional checks.
Since Solidity 0.8.0, all arithmetic operations revert on over- and underflow by default, thus making the use of these libraries unnecessary.
To obtain the previous behaviour, an unchecked block can be used:
Source: https://docs.soliditylang.org/en/v0.8.0/control-structures.html#checked-or-unchecked-arithmetic
My question is double:
- Why could I want to have behaviour that can lead to over/underflow?
- We have been using SafeMath to avoid over/underflow issues: Now it is not neccessary?