You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `safeCasting` built-in rule is there to catch cases where an explicit cast in solidity is actually out of bounds.
220
+
For example, if an `uint` is cast to a `uint64`, the rule will fail if there is some external function in the contract, that can be called
221
+
in such a way, that the value being cast is larger than `2^64 - 1`. Casting between signed and unsigned values are also checked. So if an `uint` is cast to an `int`, and the cast value is larger than `2^255 - 1`, the rule will fail.
222
+
223
+
This rule can be enabled by including
224
+
```cvl
225
+
use builtin rule safeCasting;
226
+
```
227
+
in a spec file. In addition, the line `"safe_casting_builtin" : true` must be added to the conf file.
The `uncheckedOverflow` built-in looks for cases where any of the operations `+, -, *` appearing within an `unchecked` solidity block can actually overflow.
235
+
236
+
For example:
237
+
```
238
+
function basicMul(uint128 x, uint128 y) public pure returns (uint) {
239
+
unchecked {
240
+
return x * y;
241
+
}
242
+
}
243
+
```
244
+
This will fail the builtin rule, because the multiplication is a `uint128` multiplication (even if it's later considered as a `uint`).
245
+
246
+
This rule can be enabled by including
247
+
```cvl
248
+
use builtin rule uncheckedOverflow;
249
+
```
250
+
In addition, the line `"unchecked_overflow_builtin" : true` must be added to the conf file.
0 commit comments