public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "meanarbez at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-55189-4@http.gcc.gnu.org/bugzilla/> (raw) 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 <iostream> 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; }
next reply other threads:[~2012-11-03 10:30 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-03 10:30 meanarbez at gmail dot com [this message] 2012-11-03 10:40 ` [Bug c++/55189] " glisse at gcc dot gnu.org 2012-11-03 11:11 ` meanarbez at gmail dot com 2012-11-03 13:03 ` [Bug c++/55189] enable -Wreturn-type by default redi at gcc dot gnu.org 2012-11-04 14:09 ` paolo.carlini at oracle dot com 2012-11-04 15:26 ` paolo.carlini at oracle dot com 2013-12-27 14:10 ` sylvestre at debian dot org 2014-04-17 12:05 ` sylvestre at debian dot org 2014-04-17 13:13 ` manu at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-55189-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).