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

* [Bug c++/55189] g++ compiler does not report missing return on function with return type
  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 ` glisse at gcc dot gnu.org
  2012-11-03 11:11 ` meanarbez at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-11-03 10:40 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> 2012-11-03 10:40:22 UTC ---
(In reply to comment #0)
> Compiled with MinGW port of g++, compiles without errors or warnings:

It does warn if you ask it to: -Wall


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

* [Bug c++/55189] g++ compiler does not report missing return on function with return type
  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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: meanarbez at gmail dot com @ 2012-11-03 11:11 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

--- Comment #2 from meanone <meanarbez at gmail dot com> 2012-11-03 11:11:15 UTC ---
(In reply to comment #1)
> (In reply to comment #0)
> > Compiled with MinGW port of g++, compiles without errors or warnings:
> 
> It does warn if you ask it to: -Wall

I can understand that this is ok behavior for C, but to have to
EXPLICITLY ASK typesafe language like C++ to inform me if function
WITH RETURN TYPE does not return anything ?

If this is not bug why shouldn't we make

int n;
n =;
printf("%d",n);

to be legal code, compiler should simply assign whatever it wants. Right ?

Could anyone explain what for should missing return on typical C++ function
be useful at all ?

Not to mention probability that it has been forgotten by mistake.

-Wreturn-type should be set by default.


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

* [Bug c++/55189] enable -Wreturn-type by default
  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 ` redi at gcc dot gnu.org
  2012-11-04 14:09 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2012-11-03 13:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-11-03
            Summary|g++ compiler does not       |enable -Wreturn-type by
                   |report missing return on    |default
                   |function with return type   |
     Ever Confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-11-03 13:03:14 UTC ---
(In reply to comment #2)
> If this is not bug why shouldn't we make
> 
> int n;
> n =;
> printf("%d",n);
> 
> to be legal code, compiler should simply assign whatever it wants. Right ?

No, because that's not even legal syntax, so that's a completely different
case.


> -Wreturn-type should be set by default.

OK, so let's change the report to say that then.

In general though, please don't report bugs claiming there are no warnings if
you haven't even tried -Wall, there's a notice when you report a bug asking you
to check that.

Reduced example:

struct A { int i; };

A f()
{
  A a = { 0 };
  // missing return
}

int main()
{
  A a = f();
  return a.i;
}


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

* [Bug c++/55189] enable -Wreturn-type by default
  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
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-04 14:09 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-04 14:08:44 UTC ---
Let's do this then.


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

* [Bug c++/55189] enable -Wreturn-type by default
  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
                   ` (3 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-04 15:26 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
         AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
                   |com                         |gnu.org

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-04 15:26:09 UTC ---
Sorry, not me, not now: hundreds of testcases need fixing.


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

* [Bug c++/55189] enable -Wreturn-type by default
  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
                   ` (4 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: sylvestre at debian dot org @ 2013-12-27 14:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

Sylvestre Ledru <sylvestre at debian dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sylvestre at debian dot org

--- Comment #6 from Sylvestre Ledru <sylvestre at debian dot org> ---
Patch proposed here:
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01781.html


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

* [Bug c++/55189] enable -Wreturn-type by default
  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
                   ` (5 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: sylvestre at debian dot org @ 2014-04-17 12:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

--- Comment #8 from Sylvestre Ledru <sylvestre at debian dot org> ---
The patches to fix this bug are available here:
https://github.com/sylvestre/gcc
I am doing the legal FSF papers to be able to apply it.


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

* [Bug c++/55189] enable -Wreturn-type by default
  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
                   ` (6 preceding siblings ...)
  2014-04-17 12:05 ` sylvestre at debian dot org
@ 2014-04-17 13:13 ` manu at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu.org @ 2014-04-17 13:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Sylvestre Ledru from comment #8)
> The patches to fix this bug are available here:
> https://github.com/sylvestre/gcc
> I am doing the legal FSF papers to be able to apply it.

Cool! Hopefully it goes quickly. After that, I would suggest that you submit
the patch to gcc-patches and CC Jason Merrill and Dodji Seketeli, either of
them should be able to approve this.

I noticed that your patch does not update doc/invoke.texi to reflect the fact
that -Wreturn-type is enabled by default instead of by -Wall (it would be great
to automatically generate some parts of the manual from the options
description).

I also noticed that you did not include -Wmissing-return in your patch as
discussed here: http://gcc.gnu.org/ml/gcc/2013-11/msg00288.html

(Perhaps you did, and I am using github incorrectly?)

I think you will get easier approval if you include it (or send two patches in
the same email) and point out to the previous discussion (in particular Dodji,
Joseph and Jason's approval of this idea).
>From gcc-bugs-return-449263-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 17 13:18:49 2014
Return-Path: <gcc-bugs-return-449263-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23953 invoked by alias); 17 Apr 2014 13:18:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 23901 invoked by uid 48); 17 Apr 2014 13:18:44 -0000
From: "sylvestre at debian dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55189] enable -Wreturn-type by default
Date: Thu, 17 Apr 2014 13:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.6.2
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: sylvestre at debian dot org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-55189-4-szHYqo16qr@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-55189-4@http.gcc.gnu.org/bugzilla/>
References: <bug-55189-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01283.txt.bz2
Content-length: 1392

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55189

--- Comment #10 from Sylvestre Ledru <sylvestre at debian dot org> ---
(In reply to Manuel López-Ibáñez from comment #9)
> 
> Cool! Hopefully it goes quickly. After that, I would suggest that you submit
> the patch to gcc-patches and CC Jason Merrill and Dodji Seketeli, either of
> them should be able to approve this.
Sure. Thanks for the suggestion.

> I noticed that your patch does not update doc/invoke.texi to reflect the
> fact that -Wreturn-type is enabled by default instead of by -Wall (it would
> be great to automatically generate some parts of the manual from the options
> description).
I will have a look!

> I also noticed that you did not include -Wmissing-return in your patch as
> discussed here: http://gcc.gnu.org/ml/gcc/2013-11/msg00288.html
>  
> (Perhaps you did, and I am using github incorrectly?)
I did... removed it :)
I've followed Jason suggestion here:
http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01033.html
The problem that we were trying to address with -Wmissing-return has been fixed
(AFAIK) by the commit description in comment #7

> I think you will get easier approval if you include it (or send two patches
> in the same email) and point out to the previous discussion (in particular
> Dodji, Joseph and Jason's approval of this idea).
Sure. Thanks for the advice.
>From gcc-bugs-return-449264-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 17 13:26:35 2014
Return-Path: <gcc-bugs-return-449264-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31425 invoked by alias); 17 Apr 2014 13:26:35 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 31375 invoked by uid 48); 17 Apr 2014 13:26:32 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/60866] [4.7/4.8/4.9/4.10 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion
Date: Thu, 17 Apr 2014 13:26:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.7.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-60866-4-dKx5fVaeOv@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60866-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60866-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01284.txt.bz2
Content-length: 463

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`866

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r208165 on the trunk (which can of course mean it has been latent
before).


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