warning #12178 seems to be false positive

warning #12178 seems to be false positive

I'm using -diag-enable sc3 to identify issues on my code.I would like to know if the following warning is OK, as I can't really understand it.
Basically, the code has a variable used to handle potential errors.
I'm initializing the variable to something, then putting on it the return code of the well-known printf function.Before ending, the code returns the content of that variable as program status.
My code is the following. I first stepped into this issue with a regular function, not actually main(). But it was reproducible also there.

#include int main(){ int ret = EINVAL; ret = printf(""); return ret;}

And the output is the following.

2178 8 main.c(5): warning #12178: this value of "ret" isn't used in the program /tmp/main.c 5 ret main 1

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


did you compile with optimization? I'd recommend to turn off optimizations (-O0) as they can have negative influence on the analysis. As a result you're going to see more "false positives". Those are findings in your reports that are no problems at all.

My recommendation would be those options for the build: "-g -O0".

Please keep in mind that the Intel Static Security Analysis tool will eventually bring up lots of findings. Because of static analysis principles it cannot always judge the real severity of the findings. Hence you have to decide by sighting. Using Intel Inspector XE to manage the reports you can apply filters and suppression rules.

Best regards,

Georg Zitzlsberger


AWarning #12178 - 'this value of ret isn't used in the program' is not an error or an indication of some
problem. Make your test case more complex and try to useret variable as many as possible times. That
also applies to any functions.

Best regards,

Leave a Comment

Please sign in to add a comment. Not a member? Join today