This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/47864] New: incorrect control reaches end of non-void function (switch+break+default)
- From: "ami at fischman dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 23 Feb 2011 21:37:11 +0000
- Subject: [Bug c++/47864] New: incorrect control reaches end of non-void function (switch+break+default)
- Auto-submitted: auto-generated
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.