Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350481 - parser does not detect return value
Summary: parser does not detect return value
Status: CLOSED DUPLICATE of bug 394521
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-27 14:25 EDT by Martin Gerhardy CLA
Modified: 2014-08-13 09:31 EDT (History)
5 users (show)

See Also:


Attachments
the parser does not detect the return value (958 bytes, text/plain)
2011-06-27 14:25 EDT, Martin Gerhardy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***