BUG: You receive a "fatal error C1001" error message when you try to unbox an enumeration (327972)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)

This article was previously published under Q327972

SYMPTOMS

When you try to unbox an enumeration instance, you receive the following compiler error message:
You receive a "fatal error C1001" error when you try to unbox an enumeration: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2844)
Please choose the Technical Support command on the Visual C++ Help menu,
or open the Technical Support help file for more information.

WORKAROUND

To work around this problem, cast to the underlying type of the _value enum, and then cast to the enum type. For example, to unbox an enumeration instance, instead of using the following code:
SomeEnum enum2 = *dynamic_cast<__box SomeEnum*>(obj); 
use the following code:
SomeEnum enum2 = (SomeEnum)*__try_cast<Int32*>(obj);
because the underlying type of _value enum is Int32.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Problem

  1. In Visual C++ .NET, create a new Managed C++ Application project.
  2. In the default .cpp file that is generated for your application, replace the default code with the following code:
    #include "stdafx.h"
    #using <mscorlib.dll>
    using namespace System;
    
    __value enum SomeEnum
    {
        SomeValue = 0
    };
    
    
    int main(void)
    {
    	SomeEnum enum1 = SomeValue;
    	Object* obj = __box(enum1);
    	SomeEnum enum2 = *dynamic_cast<__box SomeEnum*>(obj); 
    	return 0;
    }
    					
  3. Build the application.
You receive the error message that is described in the "Symptoms" section of this article.

REFERENCES

For additional information about Managed Extensions for C++, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:1/6/2006
Keywords:kbProd2Web kbCompiler kberrmsg kbbug kbManaged KB327972 kbAudDeveloper kbAudITPRO