This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/47864] New: incorrect control reaches end of non-void function (switch+break+default)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]