Use splint to detect always false if logic flow

41 views Asked by At

Can a flag can be set with splint to detect this logic fault?

if((a > 0) && (a == 0)){...}

The 2nd variable a is a typo. It's supposed to be b.

I've tried +ifempty and +ifblock and it turns out that they are for something else. Any suggestions? Or is it beyond splint?

1

There are 1 answers

0
AndreyKarpov On

PVS-Studio can find such an error using the V560 diagnostic. Example: https://godbolt.org/z/JA-Kmm