Microsoft KB Archive/130546

= FIX: C2227 & C2653 on Explicit Destructor Call in Template =

Article ID: 130546

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 2.1

-



This article was previously published under Q130546



SYMPTOMS
Compiling a program that includes a class template that makes an explicit reference to the destructor of the template argument  generates the following errors if the class template is instantiated with a simple type:

error C2227: left of '->type_name' must point to class/struct/union

error C2653: 'type_name' : is not a class name



RESOLUTION
The Annotated C++ Reference Manual (Jan '94), section 12.4 contains the following example: int* p;  / ... p->int::~int; But this syntax is not supported by Visual C++, even through a typeddef or template type. The only workaround is to remove the explicit call to the destructor.



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 4.0.



Sample Code to Demonstrate Problem
// Compile options needed: none template class classX { public: void funcX; Item* cpR; };

template void classX::funcX { cpR->Item::~Item; };

template classX ;

