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

Bug 355938

Summary: False positive warning about return value with try/catch
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: CLOSED DUPLICATE QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle, yevshif
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
patch that fixes the issue, including tests none

Description Nathan Ridge CLA 2011-08-26 07:57:13 EDT
For the following code:

bool f()
{
    try
    {
        return true;
    }
    catch (...)
    {
        return false;
    }
}

Codan produces the warning: "Warning: no return in function returning non-void"

However, quite obviously all code paths lead to a value being returned. gcc with -Wall produces no warning for the same code.
Comment 1 Nathan Ridge CLA 2012-11-14 05:09:35 EST
Created attachment 223553 [details]
patch that fixes the issue, including tests

Attached is a patch that fixes the issue, including tests.
Comment 2 Marc-André Laperle CLA 2012-11-15 23:51:20 EST
Thank you for the patch! Unfortunately, there was already a similar bug reported also with a patch. I will look at both patches.

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