This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28236] wrong "control reaches" warning with enums.
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jan 2007 13:57:04 -0000
- Subject: [Bug c++/28236] wrong "control reaches" warning with enums.
- References: <bug-28236-7667@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from manu at gcc dot gnu dot org 2007-01-23 13:57 -------
I don't get this. The enum value can be any integer apart from foo and bar.
Moreover, since it is undefined, it can be literally anything! So you need a
"default:" case to handle that.
In the first testcase, without a default case, the function returns (when it
reaches the end) without a value, so the warning is correct.
In the second case, r is not initialized unless __e is X or Y (and if
out-of-range enum values are undefined in C++, __e can be anything!), thus the
warning seems correct as well.
So, is this really a bug?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28236