Microsoft KB Archive/327972

= BUG: You receive a &quot;fatal error C1001&quot; error message when you try to unbox an enumeration =

Article ID: 327972

Article Last Modified on 1/6/2006

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



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 &quot;fatal error C1001&quot; 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(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.



Steps to Reproduce the Problem
 In Visual C++ .NET, create a new Managed C++ Application project.  In the default .cpp file that is generated for your application, replace the default code with the following code: using namespace System;
 * 1) include &quot;stdafx.h&quot;
 * 2) using 

__value enum SomeEnum {   SomeValue = 0 };

int main(void) {   SomeEnum enum1 = SomeValue; Object* obj = __box(enum1); SomeEnum enum2 = *dynamic_cast<__box SomeEnum*>(obj); return 0; }                    Build the application.

You receive the error message that is described in the &quot;Symptoms&quot; section of this article.

