[Bug c++/38552] New: Invalid function return path analysis error report
piotr dot wyderski at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Dec 17 11:40:00 GMT 2008
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.
--
Summary: Invalid function return path analysis error report
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: piotr dot wyderski at gmail dot com
GCC host triplet: Windows Vista 64-bit, Core2, GCC 4.3.1 (cygwin)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38552
More information about the Gcc-bugs
mailing list