This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20681] [4.4/4.5/4.6/4.7 Regression] wrong "control reaches" warning with switches
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 Nov 2011 14:53:13 +0000
- Subject: [Bug c++/20681] [4.4/4.5/4.6/4.7 Regression] wrong "control reaches" warning with switches
- Auto-submitted: auto-generated
- References: <bug-20681-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20681
--- Comment #32 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-11-15 14:53:13 UTC ---
(In reply to comment #31)
> gcc -Wreturn-type -c r.c
> r.c: In function 'bar':
> r.c:8:1: warning: control reaches end of non-void function [-Wreturn-type]
>
> enum foo { e_1 };
> int bar(enum foo x)
> {
> switch(x) {
> case e_1:
> return 0;
> }
> }
Not a bug, enum foo can have other values except e_1.
What happens if you call bar( (foo)1 ) ?