Article ID: 164000
Article Last Modified on 7/5/2005
APPLIES TO
- Microsoft Visual C++ 4.2 Enterprise Edition
- Microsoft Visual C++ 4.2 Professional Edition
This article was previously published under Q164000
SYMPTOMS
Calling typeid with a temporary object causes the following error:
RESOLUTION
Instead of calling typeid with a temporary object, create a stack object and then call typeid, referencing the stack object.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.
MORE INFORMATION
Sample Code
/* Compile options needed: none */ #include <typeinfo> struct X { X() {}; ~X() {}; }; // This main function will cause the error. void main() { const type_info& t = typeid(X()); } // For the workaround, replace main above with the following: void main() { X y; const type_info& t = typeid(y); }
Additional query words: kbVC420bug kbDSupport typeid RTTI
Keywords: kbbug kbfix kblangcpp kbvc500fix kbcpponly kbcode kbcompiler KB164000