Description
Bugzilla Link | 40962 |
Version | unspecified |
OS | All |
Extended Description
Sometimes people write code like this:
bool invalid = false;
invalid |= x > limit.x;
invalid |= y > limit.y;
invalid |= z > limit.z;
if (invalid) {
// error handling
}
However, we don't get short circuit evaluation in this case; all limits are checked even if the first limit is violated.
The alternative is to use logical operations instead of bitwise operations:
bool invalid = false;
invalid = x > limit.x;
invalid = invalid || y > limit.x;
invalid = invalid || z > limit.z;
if (invalid) {
// error handling
}
Create a check that transforms bitwise operators on boolean quantities to logical operators.