Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!ubc-cs!fornax!miron From: miron@fornax.UUCP (Miron Cuperman) Newsgroups: comp.lang.c++ Subject: Re: ``delete[]p'' -- where is the actual size of *p stored? Message-ID: <1180@fornax.UUCP> Date: 30 Aug 90 04:34:52 GMT References: <56956@microsoft.UUCP> Distribution: comp Organization: School of Computing Science, SFU, Burnaby, B.C. Canada Lines: 17 jimad@microsoft.UUCP (Jim ADCOCK) writes: >In article cline@sun.soe.clarkson.edu (Marshall Cline) writes: >> B* p = new D[100]; >> delete [] p; >C++ will already "do the wrong thing" with any attempts to address the d's >referred to by p, thus rendering any problems with delete [] p moot. >The right thing is for a compiler to issue a stern warning on the >new array statement assigned to an incompatible pointer. This is not correct. A pointer to an object may be cast to a pointer to a base class of that object. Therefore the above syntax is correct. From what I understand, the C++ implementation must save the length of the array in bytes, and deallocate it accordingly. -- By me: Miron Cuperman