home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19753 < prev    next >
Encoding:
Text File  |  1993-01-22  |  800 b   |  40 lines

  1. Path: sparky!uunet!mcsun!uknet!bradford.ac.uk!T.D.G.Sandford
  2. From: T.D.G.Sandford@bradford.ac.uk (TDG SANDFORD)
  3. Newsgroups: comp.lang.c++
  4. Subject: Result of delete operator applied to null pointer?
  5. Message-ID: <1993Jan22.145654.10001@bradford.ac.uk>
  6. Date: 22 Jan 93 14:56:54 GMT
  7. Organization: University of Bradford, UK
  8. Lines: 29
  9. Originator: 90908106@columbia
  10. Nntp-Posting-Host: columbia-fddi
  11.  
  12. Is the effect of applying the delete operator to a null pointer defined?
  13.  
  14. In particular, in the case
  15.  
  16. class x {
  17. ...
  18.     ~x();
  19. ...
  20. };
  21.  
  22. fn1
  23.  
  24. {
  25.     x *y;
  26. ... (including y = new x;)
  27.     delete y;
  28. }
  29.  
  30. should it be necessary to write
  31.  
  32.     if (y)
  33.         delete y;
  34.  
  35. to prevent the destructor for x being called if y is in fact a null pointer?
  36.  
  37. (this appears to be the case for Borland C++ v3.1).
  38. --
  39. Thomas Sandford | t.d.g.sandford
  40.