home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13564 < prev    next >
Encoding:
Internet Message Format  |  1992-09-12  |  1.4 KB

  1. Xref: sparky comp.lang.c++:13564 comp.std.c++:1163
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!taumet!steve
  4. From: steve@taumet.com (Steve Clamage)
  5. Subject: Re: operator delete[] and NULL
  6. Message-ID: <1992Sep12.172813.6282@taumet.com>
  7. Organization: TauMetric Corporation
  8. References: <18qokvINNvb@armory.centerline.com>
  9. Date: Sat, 12 Sep 1992 17:28:13 GMT
  10. Lines: 28
  11.  
  12. matt@centerline.com (Matt Landau) writes:
  13.  
  14. |Speaking of operator delete[], is the effect of calling delete[] on NULL
  15. |well-defined?  The ARM says plainly that "delete NULL" is legal, and a 
  16. |no-op, but I couldn't find anything explicit about "delete[] NULL", nor
  17. |could I find any implication that operator delete and operator delete[]
  18. |must behave the same way.
  19. |The reason I ask is that, with USL cfront 2.1.12, I have found code that
  20. |crashes intermittantly when asked to delete[] NULL.  I'm wondering if the
  21. |code is correct and cfront is buggy, or vice versa.
  22.  
  23. The ARM says on p 63:
  24.     "Deleting a pointer with the value zero, however,
  25.     is guaranteed to be harmless."
  26. This sentence immediate follows the syntax production
  27.     deallocation-expression:
  28.         delete cast-expression
  29.         delete [ ] cast-expression
  30. It doesn't restrict the guarantee to single-object deletion.
  31.  
  32. If your system doesn't allow
  33.     T *p = 0;
  34.     delete [] p;
  35. then that is a bug.
  36. -- 
  37.  
  38. Steve Clamage, TauMetric Corp, steve@taumet.com
  39. Vice Chair, ANSI C++ Committee, X3J16
  40.