how to raise warning if return value is disregarded - gcc or static code check?
Posted
by Drakosha
on Stack Overflow
See other posts from Stack Overflow
or by Drakosha
Published on 2010-01-11T15:33:03Z
Indexed on
2010/04/18
19:53 UTC
Read the original article
Hit count: 183
I'd like to see all the places in my code (C++) which disregard return value of a function. How can I do it - with gcc or static code analysis tool?
Bad code example:
int f(int z) {
return z + (z*2) + z/3 + z*z + 23;
}
int main()
{
int i = 7;
f(i); ///// <<----- here I disregard the return value
return 1;
}
Update:
- it should work even if the function and its use are in different files
- free static check tool
© Stack Overflow or respective owner