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.
*** Bug 38555 has been marked as a duplicate of this bug. ***
*** This bug has been marked as a duplicate of 20681 ***