Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327375 - IControlFlowGraph fails to detect unconnected node (dead code node)
Summary: IControlFlowGraph fails to detect unconnected node (dead code node)
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 8.7.0   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 22:25 EDT by Felipe CLA
Modified: 2015-02-18 19:47 EST (History)
3 users (show)

See Also:


Attachments
Checker implementation where we detected the described bug (1.54 KB, application/octet-stream)
2010-10-08 22:29 EDT, Felipe CLA
no flags Details
CDT project where the bug happens (23.13 KB, application/octet-stream)
2010-10-08 22:35 EDT, Felipe CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Felipe CLA 2010-10-08 22:25:14 EDT
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.
Comment 1 Felipe CLA 2010-10-08 22:29:43 EDT
Created attachment 180535 [details]
Checker implementation where we detected the described bug

Checker used to detect the bug.
Comment 2 Felipe CLA 2010-10-08 22:35:18 EDT
Created attachment 180536 [details]
CDT project where the bug happens

Sample CDT project to elaborate more on this bug.
Comment 3 Nathan Ridge CLA 2014-08-13 01:53:51 EDT
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.
Comment 5 Elena Laskavaia CLA 2015-02-18 19:47:10 EST
fixed (I hope)