Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342906 - [fn] No warning if only one of an if/else pair has a return statement
Summary: [fn] No warning if only one of an if/else pair has a return statement
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-14 20:58 EDT by Nathan Ridge CLA
Modified: 2011-04-24 22:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2011-04-14 20:58:57 EDT
For the following code:

bool g();
void h();

int f()
{
    if (g())
        h();
    else
        return 0;
}

Codan does not issue a warning about having no return statement in the if branch.

gcc gives a warning about this (with -Wall), shouldn't Codan do it too?
Comment 1 Elena Laskavaia CLA 2011-04-24 22:14:28 EDT
Added support for this. Probably would be a lot more false positives after this fix...