[Bug c++/20571] New: -Wswitch incorrectly outputs warning on ranges (regression from 3.4)

ajd at gentrack dot com gcc-bugzilla@gcc.gnu.org
Sun Mar 20 21:35:00 GMT 2005


Test program:

enum fred
{
        apple,
        orange,
        fruit_1,
        fruit_2,
        fruit_3,
};

int xx()
{
        fred e;
        switch (e) {
        case apple:
                ;
        case orange:
                ;
        case fruit_1 ... fruit_3:
                ;
        }
}

gcc 3.4 correctly accepts this code without warning.
gcc 4.0 (of Mar 17 18:06 UTC) incorrectly generates a warning.

$ /opt/gcc-3.4/bin/g++ -Wswitch -c a1.cpp
$ /opt/gcc-4.0.pre/bin/g++ -Wswitch -c a1.cpp
a1.cpp: In function 'int xx()':
a1.cpp:13: warning: enumeration value 'fruit_2' not handled in switch
a1.cpp:13: warning: enumeration value 'fruit_3' not handled in switch

-- 
           Summary: -Wswitch incorrectly outputs warning on ranges
                    (regression from 3.4)
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ajd at gentrack dot com
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list