Community
Participate
Working Groups
Build Identifier: Build id: 20111215-0110 inline const char *ICAP_Scan_status_to_string(ICAP_Scan_status iss) { switch (iss) { case ISS_NOT_SCANNED: return "ICAP_COMMUNICATION_ERROR"; case ISS_NO_MODIFICATION: return "ICAP_NO_MODIFICATION"; case ISS_REPLACEMENT: return "ICAP_REPLACED"; case ISS_SCAN_IN_PROGRESS: return "ISS_SCAN_IN_PROGRESS"; case ISS_CORRUPT_UNSCANNED_OBJECT: return "ISS_CORRUPT_UNSCANNED_OBJECT"; default: return "unknown"; } } Here, this switch doesn't cover all of the cases in the enum -- the default case isn't dead code (not that I think CODAN is thinking *that* deeply about it ;)). All paths return a value, so this is a false positive. Created in a new bug, as requested in comments to bug #350168. Reproducible: Always
Created attachment 210231 [details] Code Analysis Settings
I do have the same problem. Eclipse IDE for C/C++ Developers Version: Indigo Service Release 1 Build id: 20110916-0149
The given test case is incomplete because it does not include the definition of ICAP_Scan_status. I tried to reproduce the error by making up a definition for it, adding some other values in the enumeration beyond what is used in the switch statement. However, I am getting no warning with this with Juno: enum ICAP_Scan_status { ISS_NOT_SCANNED, ISS_NO_MODIFICATION, ISS_REPLACEMENT, ISS_SCAN_IN_PROGRESS, ISS_CORRUPT_UNSCANNED_OBJECT, SOME_OTHER_VALUE1, SOME_OTHER_VALUE2 }; inline const char *ICAP_Scan_status_to_string(ICAP_Scan_status iss) { switch (iss) { case ISS_NOT_SCANNED: return "ICAP_COMMUNICATION_ERROR"; case ISS_NO_MODIFICATION: return "ICAP_NO_MODIFICATION"; case ISS_REPLACEMENT: return "ICAP_REPLACED"; case ISS_SCAN_IN_PROGRESS: return "ISS_SCAN_IN_PROGRESS"; case ISS_CORRUPT_UNSCANNED_OBJECT: return "ISS_CORRUPT_UNSCANNED_OBJECT"; default: return "unknown"; } } Do you still see a warning in Juno? If so, could you please post a complete testcase?
Reproduced in Luna (4.4.0). Example: enum { OK = 100, WARNINGS = 200, }; int TestCase(int completionStatus) { switch (completionStatus) { case OK: return 0; case WARNINGS: return 1; default: return 2; }; }
I can reproduce the warning in comment 4 in 4.4.0, but not in a recent nightly build, suggesting that the problem was fixed (possibly in bug 455828).
Checked in Mars. Bug fixed.
Closing per comment 6.