From 2345020075240057169
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7c21e57f4a25e5f3
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-05-25 16:23:01 PST
Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!skynet.be!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: "James Kuyper Jr." <kuyper@wizard.net>
Newsgroups: comp.std.c++
Subject: Re: deleted pointers in a container
Date: Fri, 25 May 2001 23:21:37 GMT
Organization: Not Enough
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3B0EE48C.C6000E3D@wizard.net>
References: <3AF0BE2C.F07A2FB7@acm.org> <OE45ZY5sukPifCLKgE100004423@hotmail.com> <3AF69057.1778277E@acm.org> <873f7ae8.0105250552.71767b39@posting.google.com>
X-Trace: mail2news.demon.co.uk 990832935 mail2news:4467 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Accept-Language: en,es,de,ru
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 41
Xref: archiver1.google.com comp.std.c++:5301

Kiril Avdeiv wrote:
> 
> James Dennett <jdennett@acm.org> wrote in message news:<3AF69057.1778277E@acm.org>...
> > Assaf Lavie wrote:
> > >
> > > >IIRC that's not specified by the Standard.  Maybe it should
> > > >be, or maybe it is and I've just missed it.
> > >
> > > Why do you make the assertion that copying deallocated pointers (not
> > > de-referencing them) yields undefined behavior if it is not specified by the
> > > standard?
> >
> > The fact that copying deallocated pointers yields undefined
> > behaviour *is* clearly stated by the Standard.
> 
> James, I am very grateful if you show where it is stated.

3.6.3.2 says: "... the deallocation function shall deallocate the
storage referenced by the pointer, rendering invalid all pointers
referring to any part of the _deallocated storage_. The effect of using
an invalid pointer value (including passing it to a deallocation
function) is undefined."

Therefore, if you copy a deallocated pointer in any way that uses the
value, such as:

	p = q;

then the copy allows undefined behavior. If you copy it in a manner that
doesn't use the value, such as

	memcpy(&p, &q, sizeof(p));

then it's perfectly safe.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



