Help and Support
 

powered byLive Search

BUG: You receive a "fatal error C1001: INTERNAL COMPILER ERROR" error when you create an object that is a copy of a virtual function return value in Visual C++ 6.0

Article ID:226110
Last Review:April 28, 2005
Revision:3.0
This article was previously published under Q226110

SYMPTOMS

When creating an object that is a copy of a virtual function return value (a temporary object) using the compiler-supplied copy constructor, you may get the following error:
test.cpp(22) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information

Please see the steps to reproduce in the More Information section below.

Back to the top

RESOLUTION

There are four ways to get around the problem:
1.Explicitly Define a Copy Constructor. (See Workaround #1 in sample code below).
2.Remove the virtual keyword from the function which returns the value. (See Workaround #2 in sample code below).
3.Introduce a temporary variable to store the return value. (See Workaround #3 in the sample code below).
4.Remove compiler support for synchronous (C++) exception handling. This is accomplished by removing /GX (the Visual Studio default) from your compile options. (See Workaround #4 in sample code below).
Workaround #1 is the recommended workaround whenever possible.

NOTE: If you define a copy constructor, you should also define an assignment operator (operator=).

Back to the top

STATUS

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

This problem was corrected in Microsoft Visual C++ .NET.

Back to the top

MORE INFORMATION

////////////////////////////////////////////////////////////////////// 
// cl /c /GX test.cpp
// test.cpp(22) : fatal error C1001: INTERNAL COMPILER ERROR
//  (compiler file 'msc1.cpp', line 1794) 
//  Please choose the Technical Support command on the Visual C++ 
//  Help menu, or open the Technical Support help file for more information
////////////////////////////////////////////////////////////////////// 
class A
{
  public:
    /* workaround #1, add an explicit copy constructor to class A */ 
    // A(A& a) {};
    ~A() {}; 
};
class B
{
  public:
 /* workaround #2, remove virtual keyword from B::GetA */ 
    virtual A& GetA(void);
    void Func (void);
};
void B::Func (void)
{
  A *att;
  att=new A(GetA());
  /* workaround #3, substitute the above line with the following two lines */ 
  //A tmp = GetA();
  //att=new A(tmp);
}
/* workaround #4, remove /GX compiler option */ 
				

Back to the top


APPLIES TO
Microsoft Visual C++ 6.0 Enterprise Edition
Microsoft Visual C++ 6.0 Professional Edition
Microsoft Visual C++, 32-bit Learning Edition 6.0

Back to the top

Keywords: 
kberrmsg kbtshoot kbbug kbfix kbnoupdate kbcompiler KB226110

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.