C99: bool assignment error
typedef unsigned char uint8;
typedef _Bool bool;
const uint8 a = 100;
const uint8 b = 200;
test = (a==b);
Report error 1564 or 921 (cast from int to bool)
Lint should know that the assignment of
test = (a==b) is save on C99.
Additionally, in our case it could not be deactivated by -estring(921,"cast from int to bool")
Michael Metivier commented
In general, the "int vs. bool" is one of the largest sources of concern and confusion among our developers, who really want to know why something like "return (bool)(rv != 0);" is a required cast. We used to have an option to allow relationals to be treated as _Bool, but my understanding is that it only worked in conjunction with MISRA processing and has been removed from the newest iteration of the tool. I heartily support some way of handling this that doesn't involve a host of what appears to be superfluous casts all over the place.