-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
SafeMath can no longer be used as a library for uints smaller than 256 bits #1576
Comments
Good catch @BrendanChou. +1 to splitting into two different libraries ( |
Hey there @BrendanChou! I'm curious, what are you using the result of the That said, I do agree with your statement that we should provide mechanisms so that explicit casts can be avoided. I see a couple ways to move forward with this:
Regarding the immediate future, I'd get the signed operations into a |
Fixed by #1588. Not sure why GitHub didn't close this issue. |
@nventuro Afterwards, using my own simple library to do a safe down-cast to uint128 |
Can no longer use SafeMath as an in-line library for unsigned integers smaller than 256 bits.
💻 Environment
Truffle 5 and OpenZeppelin 2.1
📝 Details
This is because there are new functions for signed integers in SafeMath. Recommend splitting into two different files so that both unsigned ints and signed ints of less than 256 bits can be used without first casting to uint256 or int256. Casting like this can result in hard-to-detect bugs.
🔢 Code to reproduce bug
results in the error:
Member "add" not unique after argument-dependent lookup in type(library SafeMath).
The text was updated successfully, but these errors were encountered: