home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!bradford.ac.uk!T.D.G.Sandford
- From: T.D.G.Sandford@bradford.ac.uk (TDG SANDFORD)
- Newsgroups: comp.lang.c++
- Subject: Result of delete operator applied to null pointer?
- Message-ID: <1993Jan22.145654.10001@bradford.ac.uk>
- Date: 22 Jan 93 14:56:54 GMT
- Organization: University of Bradford, UK
- Lines: 29
- Originator: 90908106@columbia
- Nntp-Posting-Host: columbia-fddi
-
- Is the effect of applying the delete operator to a null pointer defined?
-
- In particular, in the case
-
- class x {
- ...
- ~x();
- ...
- };
-
- fn1
-
- {
- x *y;
- ... (including y = new x;)
- delete y;
- }
-
- should it be necessary to write
-
- if (y)
- delete y;
-
- to prevent the destructor for x being called if y is in fact a null pointer?
-
- (this appears to be the case for Borland C++ v3.1).
- --
- Thomas Sandford | t.d.g.sandford
-