| BUG: Deleting Pointer of Pointer Gives Ambiguous Error MessageLast reviewed: July 18, 1997Article ID: Q130218 | 
| 1.00 1.50 1.51 1.52
WINDOWS
kbprg kbfixlist kbbuglist The information to this article applies to : 
 SYMPTOMS An attempt to delete a pointer to a pointer to a const causes the compiler to generate the following ambiguous error message: Error C2665 : 'delete' : 4 overloads have no legal conversion for parameter 1 RESOLUTIONTo resolve this problem, use delete with a cast expression, as shown here: 
 delete [] cast-expression -or- delete cast-expressionYou can also resolve the problem by using the following code: 
    /*The following program resolves the problem:
   tyepedef const char *constcharstar;
   void main(void)
   {
      int num = 5;
      constcharstar *sects = new constcharstar[num];
      sects[2] = "abcd";
   delete [] (char **) sects;// suggested resolution for error C2665
                             // or " delete (char **) sects; "
   }
STATUSMicrosoft 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++ for Windows NT, versions 1.0, 2.0, and 2.1. 
 MORE INFORMATION
 Sample Code to Reproduce Problem
 /* No special compile options needed. */ /* The following program reproduces the problem:typedef const char *constcharstar; 
 void main(void){ int num = 5; constcharstar *sects = new constcharstar[num]; sects[2] = "abcd"; delete sects; // error C2665 , ambiguous error} 
 | 
| Additional reference words: 1.00 1.50 1.51 1.52 8.00 8.00c no32bit noupdate 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use. |