Community
Participate
Working Groups
Build Identifier: I20100603-1500 Given the following C code the last statement is NOT reported as unconnected node after calling getUnconnectedNodeIterator() void called_from_macro() { int variable = 0; if (variable) { return; } else { return; } variable += 10; } Reproducible: Always Steps to Reproduce: 1.Create a CDT project with a C function like the one cited in the details section. 2.Create a CODAN checker in order to catch function definitions. 3.Create an IControlFlowGraph over the function definition and get the number of unconnected nodes. getUnconnectedNodeSize() 4.-Set a break point where the problematic function is processed and verify zero unconnected nodes are reported by the IControlFlowGraph.
Created attachment 180535 [details] Checker implementation where we detected the described bug Checker used to detect the bug.
Created attachment 180536 [details] CDT project where the bug happens Sample CDT project to elaborate more on this bug.
This problem can also manifest as a user-visible false-positive Codan warning, if you change the return type of the function to non-void (and change the return statements accordingly): int called_from_macro() { // WARNING HERE: No return, in function returning non-void int variable = 0; if (variable) { return 2; } else { return 3; } variable += 10; } GCC, which has a similar warning, does not warn for this code.
Gerrit change https://git.eclipse.org/r/42092 was merged to [master]. Commit: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=3cf5ec86eef49327bd52622b702ca65c6af68472
fixed (I hope)