BUG: Redefining enum Should Cause an Error But Does Not
  
PSS ID Number: Q129414
Article last modified on 10-12-1995
 
1.00 2.00 2.10
 
WINDOWS NT
 

---------------------------------------------------------------------
The information in this article applies to:
 
 - The Microsoft C/C++ Compiler (CL.EXE) included with:
   Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, and 2.1
---------------------------------------------------------------------
 
SYMPTOMS
========
 
When you use an enum in class scope and again in global scope, the compiler
should generate an error but does not. Once redefined, using those enum
types has unpredictable results.
 
RESOLUTION
==========
 
Define an enum only once within any scope.
 
STATUS
======
 
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
 
MORE INFORMATION
================
 
Steps to Reproduce Problem
--------------------------
 
Compile the sample code below. It should produce an error. However, for
the products listed above, the compiler does not produce an error.
 
Sample Code
-----------
 
/* Compile options needed: none
*/
 
class   Test
{
 public:
   enum status {a = 2, b};
};
 
enum Test::status {a = 4, b, c};   // Should be an error
 
REFERENCES
==========
 
The Annotated C++ Reference Manual (Jan '94) section 7.2.
 
Additional reference words: 1.00 2.00 2.10 8.00 9.00 9.10
KBCategory: kbtool kbbuglist
KBSubcategory: CPPIss
=============================================================================
Copyright Microsoft Corporation 1995.
