Microsoft KB Archive/130218

From BetaArchive Wiki

BUG: Deleting Pointer of Pointer Gives Ambiguous Error Message

Q130218

1.00 1.50 1.51 1.52 WINDOWS kbprg kbfixlist kbbuglist --------------------------------------------------------------------- The information to this article applies to : - The Microsoft C/C++ Compiler (CL.EXE) incuded with: Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52 --------------------------------------------------------------------- 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 RESOLUTION ========== To resolve this problem, use delete with a cast expression, as shown here: delete [] cast-expression -or- delete cast-expression You 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; " } 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++ 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 KBCategory: kbprg kbfixlist kbbuglist KBSubcategory: CPPIss

Keywords : kb16bitonly kbCompiler kbCPPonly kbVC
Issue type :
Technology :


Last Reviewed: July 24, 1997
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.