BUG: You may receive the "fatal error C1001: internal compiler error" error message when you try to export a class by using Visual C++ .NET (325570)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)

This article was previously published under Q325570

SYMPTOMS

When you try to compile code that is similar to the sample code that appears in the "Steps to Reproduce the Behavior" section of this article, you may receive the following error message:
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2844)

CAUSE

This behavior occurs only under the following conditions:
  • You apply __declspec(dllexport) to a class that has a base class that does not have __declspec(dllexport).

    -and-
  • The base class has multiple base classes that have virtual functions.

RESOLUTION

To work around the issue, do one of the following:
  • Explicitly export the base class C by using the following syntax:

    template struct __declspec (dllexport) C<int>;

    -or-
  • Make one of the functions non-virtual.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ .NET (2003).

MORE INFORMATION

Steps to Reproduce the Behavior

To reproduce the problem, try to compile the following code:
//test.cpp
// Compiler Option: cl /c test.cpp
struct __declspec (dllexport) A
{
	virtual ~A(void){}
};

struct __declspec (dllexport) B
{
	virtual ~B(void){}
};

template <class T>
struct  C : A, B
{
};

//template struct __declspec (dllexport) C<int>;//WORKAROUND 1

struct __declspec (dllexport) D : C<int>
{
};

				

Modification Type:MinorLast Reviewed:1/17/2006
Keywords:kbfix kbbug kbCompiler kberrmsg kbpending KB325570 kbAudDeveloper