Detects when a program accesses a Boolean variable and its value isn’t true or false.
- Xcode 9.0+
This check detects accesses a Boolean variable when its value isn’t true or false. This problem can occur when an integer or pointer is used without an appropriate cast. The use of out-of-range Boolean values has undefined behavior, which can be difficult to debug.
Invalid Boolean Variable Access in C
The intent of the following code is to call the
success function when
result is nonzero. However, because a Boolean check is used, the compiler may, as an optimization, only emit instructions that check the least-significant bit of
predicate, which is
0, causing a logic error.
Use integer comparison instead of a Boolean check.