This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[c++] switch ( enum ) vs. default statment.
- From: PaweÅ Sikora <pluto at agmk dot net>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 23 Jan 2007 20:16:59 +0100
- Subject: [c++] switch ( enum ) vs. default statment.
Hi,
Please consider following testcase which is a core of PR c++/28236.
typedef enum { X, Y } E;
int f( E e )
{
switch ( e )
{
case X: return -1;
case Y: return +1;
}
}
In this example g++ produces a warning:
e.cpp: In function âint f(E)â:
e.cpp:9: warning: control reaches end of non-void function
Adding `default' statemnet to `switch' removes the warning but
in C++ out-of-range values in enums are undefined.
I see no reason to handling any kind of UB ( especially this ).
IMHO this warning is a bug in C++ frontend.
Comments are appreciated.
BR,
PaweÅ.