home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:13564 comp.std.c++:1163
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: operator delete[] and NULL
- Message-ID: <1992Sep12.172813.6282@taumet.com>
- Organization: TauMetric Corporation
- References: <18qokvINNvb@armory.centerline.com>
- Date: Sat, 12 Sep 1992 17:28:13 GMT
- Lines: 28
-
- matt@centerline.com (Matt Landau) writes:
-
- |Speaking of operator delete[], is the effect of calling delete[] on NULL
- |well-defined? The ARM says plainly that "delete NULL" is legal, and a
- |no-op, but I couldn't find anything explicit about "delete[] NULL", nor
- |could I find any implication that operator delete and operator delete[]
- |must behave the same way.
- |The reason I ask is that, with USL cfront 2.1.12, I have found code that
- |crashes intermittantly when asked to delete[] NULL. I'm wondering if the
- |code is correct and cfront is buggy, or vice versa.
-
- The ARM says on p 63:
- "Deleting a pointer with the value zero, however,
- is guaranteed to be harmless."
- This sentence immediate follows the syntax production
- deallocation-expression:
- delete cast-expression
- delete [ ] cast-expression
- It doesn't restrict the guarantee to single-object deletion.
-
- If your system doesn't allow
- T *p = 0;
- delete [] p;
- then that is a bug.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-