Code below presents behavior which I think is incorrect:

class A
{
    enum class Color { Red, Orange, Yellow, Green, Blue, Violet };
    enum class Alert { Green, Yellow, Red };
};

$ g++-4.4.0-alpha20081010  -c -std=c++0x /tmp/enum_class.cc 
/tmp/enum_class.cc:4: error: declaration of ‘Green’
/tmp/enum_class.cc:3: error: conflicts with previous declaration ‘A::Color
A::Green’
/tmp/enum_class.cc:4: error: declaration of ‘Yellow’
/tmp/enum_class.cc:3: error: conflicts with previous declaration ‘A::Color
A::Yellow’
/tmp/enum_class.cc:4: error: declaration of ‘Red’
/tmp/enum_class.cc:3: error: conflicts with previous declaration ‘A::Color
A::Red’

Moreover, code:

class A
{
    enum class Color { Red, Orange, Yellow, Green, Blue, Violet };
    static const Color x = Red;
};

is incorrectly accepted.

This behavior is consistent in both versions i have checked, namely
gcc-g++-20080912 and gcc-g++-20081010.


-- 
           Summary: [c++0x] Invalid handling of scoped enums defined at
                    class scope
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: piotr dot rak at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to