If an identifier given inside an enum is the same as an existing class
the compiler still accepts it:

<<< code <<<
class MyClass { };
MyClass g_my_class;  // An instance

enum { Mode1, MyClass };  // We could have error already here

MyClass g_my_class2;  // Compiler gives error here
<<< endcode <<<


For functions the desired behaviour is there:
<<< code <<<
int MyFunc() { return 0; }

enum { Mode1, MyFunc };  // Compiler objects here
<<< endcode <<<

Inside an enum it is very seldom the purpose to overwrite a class or template
in the global namespace. It is accidental, so an early error from the compiler
would be good.

Also template names can be overwritten inside enums.

Regards
Arne Steinarson


-- 
           Summary: class name permitted in enum
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: asteinarson at gmail dot com
 GCC build triplet: Linux, Ubuntu 7.04
  GCC host triplet: Linux, Ubuntu 7.04
GCC target triplet: Linux, Ubuntu 7.04


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

Reply via email to