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

Bug 394521

Summary: False positive "no return" warning in function with infinite loop
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse, frantas, kamre, martin.gerhardy, samh.public, yevshif
Version: Next   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2012-11-17 17:28:51 EST
(Simplified from testcase in https://bugs.eclipse.org/bugs/show_bug.cgi?id=348387#c3)

Codan gives a false positive warning for the following function:

int test1_f()    // WARNING HERE: "No return, in function returning non-void"
{
    while (1) 
    {
    }
}
Comment 1 Missing name CLA 2013-04-25 18:40:35 EDT
This seems to be related: not infinite, but a do/while(0) loop (commonly used with macros) gives the same warning (Eclipse 3.8.2 / CDT 8.1.2):

int test1() {
    do {
        return 1;
    } while (0);
}
Comment 2 Nathan Ridge CLA 2014-07-10 01:13:43 EDT
Looks like this was fixed a couple of weeks ago in http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=db43e03878e285348d08ddab9ae034edf669da70. Thanks Alena!
Comment 3 Elena Laskavaia CLA 2014-08-13 09:30:26 EDT
*** Bug 353951 has been marked as a duplicate of this bug. ***
Comment 4 Elena Laskavaia CLA 2014-08-13 09:31:35 EDT
*** Bug 350481 has been marked as a duplicate of this bug. ***
Comment 5 Nathan Ridge CLA 2016-12-22 00:20:23 EST
*** Bug 380749 has been marked as a duplicate of this bug. ***