BUG: Internal Compiler Error Creating a Copy of a Temporary ObjectID: Q226110
|
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
There are four ways to get around the problem:
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
//////////////////////////////////////////////////////////////////////
// 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 */
Additional query words: Internal Compiler Error ICE C1001
Keywords : kbCompiler kbVC600bug
Version : winnt:6.0
Platform : winnt
Issue type : kbbug
Last Reviewed: June 1, 1999