Is there some way to detect the bad usage of bool
values in code like
#include <stdbool.h>
void *foo(void)
{
return false;
}
int bar(void)
{
return true;
}
Both functions are accepted by gcc
(8.3.1) and clang
(7.0.1) without any warnings
$ gcc -Wall -W -pedantic -c x.c
$ clang -Xclang -analyzer-checker=alpha --analyze -Wall -W -pedantic -c x.c
$ clang -Wall -W -pedantic -c x.c
$
Compiling as C++ code would detect the problem in foo()
but is not an option but rest of code is C, not C++.
Are there other (-W
) options or switches which would create diagnostics for these cases?
#define log_err(_fmt, ...)
). – Harbert