Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

warning #12178 seems to be false positive

Andres_M_Intel4
Employee
364 Views
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
0 Kudos
2 Replies
Georg_Z_Intel
Employee
364 Views
Hello,

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
0 Kudos
SergeyKostrov
Valued Contributor II
364 Views

Hi,

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,
Sergey

0 Kudos
Reply