Topic: MSVC bug ? syntax error


Author: bnathan@ncratl.AtlantaGA.NCR.COM (Bob Nathan)
Date: Wed, 5 May 1993 17:34:32 GMT
Raw View
I took a Microsoft seminar last year on C++ 7.0.  When I found
that the following wouldn't compile correctly, I asked the instructor
who asked MS, but I never got a good answer.  When I got
BC++ 3.1, I tried it, and it compiles fine, as I would expect.
But since it still doesn't compile correctly in MSVC (C++ 8.0),
I need confirmation from some knowledgable individual(s) out there
that this syntax is O.K.  The Microsoft compiler complains that
it cant find a conversion for parameter 1 on the "delete" statement.

Of course, the snippet below has been reduced.  It can be reduced
further, I suppose, but this is where my testing finally stabilized.
===========================
class MyClass
{ public:
  int value;
  MyClass::MyClass(int v) {value=v;}
};

int main()
 { int i;
   const MyClass t(3);
   // ppt is a pointer to a pointer to a constant MyClass
   const MyClass **ppt;
   // ppt points to a new pointer,
   //   which should point to a constant MyClass
   ppt = new  const MyClass *;
   // initialize the pointer to which ppt points
   //   with the address of t.
   *ppt = &t;
   i = (*ppt)->value; // prove the addressing works
   //  I want to delete the pointer which points to t,
   //    which I "new'd" 2 lines back.
   delete ppt;
   return 0;
}
=======================
Bob.Nathan@AtlantaGA.NCR.COM
=======================




Author: jimad@microsoft.com (Jim Adcock)
Date: 06 May 93 18:38:03 GMT
Raw View
In article <C6KE5M.8Gt@ncratl.AtlantaGA.NCR.COM> bnathan@ncratl.AtlantaGA.NCR.COM (Bob Nathan) writes:
|But since it still doesn't compile correctly in MSVC (C++ 8.0),
|I need confirmation from some knowledgable individual(s) out there
|that this syntax is O.K.  The Microsoft compiler complains that
|it cant find a conversion for parameter 1 on the "delete" statement.

I double-checked with the VC++ compiler writers and this is indeed a
known bug with the MS C++ compilers that didn't get fixed in time for
the VC++ release -- sigh.  The workaround is to include an explicit
cast in the delete statement.  Sorry.