public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55189] New: g++ compiler does not report missing return on function with return type
@ 2012-11-03 10:30 meanarbez at gmail dot com
  2012-11-03 10:40 ` [Bug c++/55189] " glisse at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: meanarbez at gmail dot com @ 2012-11-03 10:30 UTC (permalink / raw)
  To: gcc-bugs


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;
        }


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-17 13:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-03 10:30 [Bug c++/55189] New: g++ compiler does not report missing return on function with return type meanarbez at gmail dot com
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

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).