public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47864] New: incorrect control reaches end of non-void function (switch+break+default)
@ 2011-02-23 22:09 ami at fischman dot org
  2011-02-23 22:32 ` [Bug c++/47864] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: ami at fischman dot org @ 2011-02-23 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: incorrect control reaches end of non-void function
                    (switch+break+default)
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ami@fischman.org


Using -finstrument-functions together with a switch statement containing a
"break;" can result in incorrect warning about reaching the end of a non-void
function, even when the "break;" is a no-op (because it follows an
unconditional return statement).

$ nl t.cc ; g++ -finstrument-functions -Wreturn-type -Werror -c t.cc
     1  int foo(int type) {
     2    switch(type) {
     3      case 0: return 1; break;
     4      default: return 0;
     5    }
     6  }
cc1plus: warnings being treated as errors
t.cc: In function ‘int foo(int)’:
t.cc:6: error: control reaches end of non-void function

This is with:
$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3

Doing either of:
- remove the "break;"
- build without -finstrument-functions
makes gcc stop emitting the incorrect warning.


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

* [Bug c++/47864] incorrect control reaches end of non-void function (switch+break+default)
  2011-02-23 22:09 [Bug c++/47864] New: incorrect control reaches end of non-void function (switch+break+default) ami at fischman dot org
@ 2011-02-23 22:32 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-02-23 22:32 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-02-23 22:08:42 UTC ---
This is exactly the same issue as PR 20681.  The issue is that is try finally
block which will produce a fallthrough which is not needed.

*** This bug has been marked as a duplicate of bug 20681 ***


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

end of thread, other threads:[~2011-02-23 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-23 22:09 [Bug c++/47864] New: incorrect control reaches end of non-void function (switch+break+default) ami at fischman dot org
2011-02-23 22:32 ` [Bug c++/47864] " pinskia 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).