Closed
Description
Affected rules
- M0-1-10
Description
The class MainFunction
defined in EncapsulatingFunctions.qll doesn't consider int32_t main()
as a "main" function. Due to this, multiple false positives get raised in case the user has defined main
with int32_t
return type.
Example
Definitions of func1 and func2 are left out for reasons of brevity.
namespace mains {
static int32_t var;
// @brief namespace_func
static void namespace_func(void) noexcept { // FP: Function is reported as not called, but it is called from "main" below.
mains::var = -1;
return;
}
} // namespace
// @brief main
// @return exit code
int32_t main(void) {
int32_t ret {0};
try {
ret = func1(); // FP: Reported as not called in the definition location
mains::var += ret;
ret = func2(); // FP: Reported as not called in the definition location
mains::var += ret;
}
catch(...) {
mains::namespace_func(); // namespace_func is called here.
}
return ret;
}