Bug 38552 - Invalid function return path analysis error report
Summary: Invalid function return path analysis error report
Status: RESOLVED DUPLICATE of bug 20681
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 38555 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-12-17 11:39 UTC by Piotr Wyderski
Modified: 2008-12-22 02:36 UTC (History)
10 users (show)

See Also:
Host: Windows Vista 64-bit, Core2, GCC 4.3.1 (cygwin)
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Wyderski 2008-12-17 11:39:10 UTC
The following snippet:

------------8<-------------

#include <memory>

typedef std::auto_ptr<int> v_type;

v_type fn(int v) {

    v_type r(new int(4));

    switch(v) {

        case 1:
        case 2: {

            return v_type(new int(5));

        } break;

        default:

            return r;
    }
}

int main(int argc, char *argv[])
{
    fn(4);
    return 0;
}

------------8<-------------

compiled with:

 g++ -Wall -Werror test.cpp

errornously produces:

error: control reaches end of non-void function

However, clearly, all control flow paths do return some result.
Without the "break" statement the code compiles flawlessly.
Comment 1 Paolo Carlini 2008-12-17 15:31:58 UTC
*** Bug 38555 has been marked as a duplicate of this bug. ***
Comment 2 Andrew Pinski 2008-12-22 02:36:24 UTC

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