BUG: Can't Use Simple Type in an Explicit Call of a Destructor

Last reviewed: July 31, 1997
Article ID: Q129132
The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C/C++ version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52 - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 2.1, 4.0,

         4.1, 4.2, 5.0
    

SYMPTOMS

The notation for an explicit call of a destructor may be used for any simple type name. Using the notation for a type that does not have a destructor has no effect. However, for the products mentioned above, the use of a simple type name causes the following compiler errors:

   t.cpp(6): error C2611: 'int' : illegal following '~'
   (expected identifier)
   t.cpp(6): error C2062: type 'int' unexpected

RESOLUTION

The Annotated C++ Reference Manual (Jan '94), section 12.4 contains the following example:

   int* p;
   / ...
   p->int::~int();

However, the current language grammar restricts the use of the ->~ and :: syntax to class names. Because at the current time simple types are not considered class names, the above syntax is not implemented by the compiler.

Until this language feature is implemented, removing the code is the only resolution.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Using an explicit call of a destructor for a simple type would have no effect, so removing it will not affect the compiled code. However this may not be easy to do when this code is part of a macro expansion or templated class that should be able to accept both built-in and user-defined types.

REFERENCES

For more information, see The Annotated C++ Reference Manual (Jan '94), section 12.4

Sample Code

   /* No special compile options needed. */
   void main(void)
   {
      int*    p;
      p->int::~int();     // Generates C2611 error
   }


Additional query words: 8.00 8.00c 9.00 9.10 template 10.00 10.10 10.20
Keywords : CPPIss vcbuglist400 vcbuglist500
Version : 7.0 1.0 1.5 1.51 1.52 2.0 2.1 4.
Platform : MS-DOS NT WINDOWS
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 31, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.