BUG: Redefinition of Enum Data Type Does Not Cause an Error

Last reviewed: July 24, 1997
Article ID: Q128600
The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft Visual C++, 32-bit Edition, versions 2.0, 2.1, 4.0, 4.1,

         4.2, 5.0
    

SYMPTOMS

When an enumerated type is declared in class scope, if it is declared again at global scope, the compiler will not generate an error. However, once redefined, the result of using those enumerated types is unpredictable.

RESOLUTION

An enumerated type should be defined 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 problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Sample Code to Demonstrate Problem

   /* Compiler options needed: /c
   */

   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" by Ellis and Stroustrup (Jan 1994), section 7.2


Additional query words: 9.00 9.10 10.10 10.20
Keywords : CPPIss vcbuglist400 vcbuglist500
Version : 1.0 2.0 2.1 4.0 4.1 4.2
Platform : NT WINDOWS
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.