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/18715] New: warning: "enumeration value not handled in switch" for '...' ranges


gcc (GCC) 4.0.0 20041121 (experimental)

-Wswitch-enum generates the warning even if the range in
case expression covers all possible values of a enum.
The first value of the range (a0 in the example below)
is not listed as missing (but all others, including the
last). The generated code works properly, though.

Example:

enum a { a0, a1, a2, a3 };

int error(enum a aa)
{
  switch ( aa )
  {
  case a0 ... a3:
    return 1;
  }
  return 0;
}

Output:
gcc4-enum.c: In function 'error':
gcc4-enum.c:5: warning: enumeration value 'a1' not handled in switch
gcc4-enum.c:5: warning: enumeration value 'a2' not handled in switch
gcc4-enum.c:5: warning: enumeration value 'a3' not handled in switch

GCC (from gcc-4.0-20041121 snapshot) configured and compiled:
../gcc-4.0-20041121/configure --enable-threads --with-tune=pentium4
--disable-nls --enable-languages=c,c++
(removing -mtune=pentium4 didn't help)

-- 
           Summary: warning: "enumeration value not handled in switch" for
                    '...' ranges
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fork0 at users dot sf dot net
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18715


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