for the following code wrong "missing return" findings are created:
"Found a exit path from function with non-void return type that has missing return statement"
autofoo4()->void{asset.close();}virtual~FL(){};
Also, for these kinds of code examples such wrong findings are created; however I don't know yet why in this specific "artificial code" they don't show up. So here my question is: are "implicit returns" like assert/throw taken into consideration? Sometimes that does not seem to be the case.
So here my question is: are "implicit returns" like assert/throw taken into consideration? Sometimes that does not seem to be the case.
Implicit returns are also considered. If the "return 0" is removed, the warning is written for the "break;".. if that break; is reached in any way then there will be undefined behavior.
since it's pretty common to write extra redundant breaks in switch statements, as in your code, I think it would be good to add a special heuristic for this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's another (at least in our code, common) example:
void VNCCALL foo()
{
int a=3;
}
VNCCALL is a macro that cppcheck doesn't seem to be able to resolve, I don't know why; it is (somewhere else) defined as:
#define VNCCALL __stdcall
So the real problem seems to be that cppcheck can't find the macro definition there, but it assumes something about this unknown token that leads to an FP regarding "missing return statement".
What would you suggest?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok .... then I'll just add one more (to be honest, obscure-looking) example:
voidvirtualfoo(const::a::b::c::d::e::bar&){};
"void virtual" instead of "virtual void" seems to be allowed according to: https://en.cppreference.com/w/cpp/language/declarations "Declaration specifiers (decl-specifier-seq) is a sequence of the following whitespace-separated specifiers, in any order: ..."
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
for the following code wrong "missing return" findings are created:
"Found a exit path from function with non-void return type that has missing return statement"
Also, for these kinds of code examples such wrong findings are created; however I don't know yet why in this specific "artificial code" they don't show up. So here my question is: are "implicit returns" like assert/throw taken into consideration? Sometimes that does not seem to be the case.
Best regards,
Martin
Implicit returns are also considered. If the "return 0" is removed, the warning is written for the "break;".. if that break; is reached in any way then there will be undefined behavior.
since it's pretty common to write extra redundant breaks in switch statements, as in your code, I think it would be good to add a special heuristic for this.
Thanks for fixing the first issues!
Here's another (at least in our code, common) example:
VNCCALL is a macro that cppcheck doesn't seem to be able to resolve, I don't know why; it is (somewhere else) defined as:
So the real problem seems to be that cppcheck can't find the macro definition there, but it assumes something about this unknown token that leads to an FP regarding "missing return statement".
What would you suggest?
There is a ticket for this issue here.
Ok .... then I'll just add one more (to be honest, obscure-looking) example:
"void virtual" instead of "virtual void" seems to be allowed according to: https://en.cppreference.com/w/cpp/language/declarations "Declaration specifiers (decl-specifier-seq) is a sequence of the following whitespace-separated specifiers, in any order: ..."