From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5506 invoked by alias); 3 Nov 2012 10:30:24 -0000 Received: (qmail 5336 invoked by uid 48); 3 Nov 2012 10:30:05 -0000 From: "meanarbez at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55189] New: g++ compiler does not report missing return on function with return type Date: Sat, 03 Nov 2012 10:30:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: meanarbez at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00202.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189 Bug #: 55189 Summary: g++ compiler does not report missing return on function with return type Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: meanarbez@gmail.com Compiled with MinGW port of g++, compiles without errors or warnings: g++ bug.cpp -o bug.exe Minimal sample bug.cpp: #include using namespace std; class Example { protected: int m_x; public: Example() { m_x = 0; } Example( const Example &ref ) { m_x = ref.m_x; } ~Example() { } int get() { return m_x; } void set( int x ) { m_x = x; } Example &operator =( Example ref ) { m_x = ref.m_x; return *this; } }; Example func( Example p ) { Example m; m.set( p.get() ); // ! COMPILER DOES NOT DETECT ABSENCE OF FUNCTION RETURN ! } int main() { Example m; m.set( 7 ); Example k; k = func( m ); // ! CONSEQUENTLY RESULT IS RANDOM ! cout << k.get() << endl; return 0; }