Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355938 - False positive warning about return value with try/catch
Summary: False positive warning about return value with try/catch
Status: CLOSED DUPLICATE of bug 348387
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-26 07:57 EDT by Nathan Ridge CLA
Modified: 2012-11-15 23:51 EST (History)
3 users (show)

See Also:


Attachments
patch that fixes the issue, including tests (4.33 KB, patch)
2012-11-14 05:09 EST, Nathan Ridge CLA
no flags Details | Diff

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