Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 350481

Summary: parser does not detect return value
Product: [Tools] CDT Reporter: Martin Gerhardy <martin.gerhardy>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: CLOSED DUPLICATE QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, frantas, malaperle, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
the parser does not detect the return value none

Description Martin Gerhardy CLA 2011-06-27 14:25:27 EDT
Created attachment 198671 [details]
the parser does not detect the return value

the parser does not detect the return value of the attached function
Comment 1 Martin Gerhardy CLA 2011-06-27 14:26:10 EDT
the reported warning is:

"Description	Resource	Path	Location	Type
No return, in function returning non-void	infostring.c	/ufoai/src/shared	line 39	Code Analysis Problem"
Comment 2 Martin Gerhardy CLA 2011-06-28 01:43:00 EDT
looks this bug is also triggered for:

int foo(void) {
[...]
{
return 0;
}
}
Comment 3 Tomasz Wesolowski CLA 2011-07-28 12:57:57 EDT
For the case from comment 2, this was already fixed (bug 345687)

For the case from attachment 198671 [details] - the warning is reported because control flow analysis looks into control structures, but not values. Hence it doesn't know that the `while` is an infinite loop, it assumes there is a branch out of the loop and it leads to no return.

A simplified test case:

int foo() {
	int a = 5;
	while (1) {
		--a;
		if (a == 0) {
			return 5;
		}
	}
}

Data flow analysis is planned for the future. Alena, shall we make a workaround for the time being?
Comment 4 Tomasz Wesolowski CLA 2011-07-28 13:02:37 EDT
propose new summary -> [fp] Wrong warning "No return, in function returning non-void" after a while(1) loop
Comment 5 Elena Laskavaia CLA 2011-08-20 13:23:24 EDT
I would just leave it as false positive now - analyzing loops for to be infinitive is quite difficult
Comment 6 Nathan Ridge CLA 2014-08-13 01:56:41 EDT
This appears to be fixed by the patch for bug 394521. I think we can close as duplicate.
Comment 7 Elena Laskavaia CLA 2014-08-13 09:31:35 EDT

*** This bug has been marked as a duplicate of bug 394521 ***