On the left-hand side of the equality check, there is an assignment of the variable outputAmt_
.
The right-hand side uses the same variable.
The Solidity 0.7.3. documentation states that “The evaluation order of expressions is not specified (more formally, the order in which the children of one node in the expression tree are evaluated is not specified, but they are of course evaluated before the node itself).
It is only guaranteed that statements are executed in order and short-circuiting for boolean expressions is done” which means that this check constitutes an instance of undefined behavior.
As such, the behavior of this code is not specified and could change in a future release of Solidity.
Short term, rewrite the if statement such that it does not use and assign the same variable in an equality check. Long term, ensure that the codebase does not contain undefined Solidity or EVM behavior.
- ToB Audit DFX Finding 10
- Undefined Behavior
- High Severity
- Variable Assign & Use
- LHS & RHS Check
- Rewrite Expression
- Avoid Undefined Behavior
- Youtube Reference
- High Risk severity finding from ToB’s Audit of DFX Finance