From -2389379351109589159
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7c21e57f4a25e5f3
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-05-27 12:06: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: kavdeiv@mail.ru (Kiril Avdeiv)
Newsgroups: comp.std.c++
Subject: Re: deleted pointers in a container
Date: Sun, 27 May 2001 19:05:54 GMT
Organization: http://groups.google.com/
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <873f7ae8.0105271040.32362b99@posting.google.com>
References: <3AF0BE2C.F07A2FB7@acm.org> <OE45ZY5sukPifCLKgE100004423@hotmail.com> <3AF69057.1778277E@acm.org> <873f7ae8.0105250552.71767b39@posting.google.com> <3B0EE5D3.7C7D90B6@acm.org>
X-Trace: mail2news.demon.co.uk 990990359 mail2news:21673 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)
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Date: 27 May 2001 18:40:19 GMT
Lines: 68
Xref: archiver1.google.com comp.std.c++:5347

James Dennett <jdennett@acm.org> wrote in message news:<3B0EE5D3.7C7D90B6@acm.org>...
> 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.
> 
> 5.3.5/4 contains "Note: the value of a pointer that refers to
> deallocated storage is indeterminate." but I don't think that's
> the piece I want.
> 
> Ah...  3.7.3.2/4 is the one: "If the argument given to a
> deallocation function in the standard library is a pointer that
> is not the null pointer value (4.10), the deallocation function
> shall deallocate the store 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 passint it to a deallocation function) is undefined."
> 
> There's a footnote (33) which points out that "On some
> implementations, it causes a system-generated runtime fault."
> 
> If you agree that copying a pointer is a "use" of the pointer,
> this clearly states that
> 
> int *p(new int);
> delete p;  // invalidates p
> int *q(p); // use of invalid pointer 
> 
> invokes undefined behaviour.

Thank you for the answer.

However, the standard says "an object or a non-overloaded function is
used if it appears in a potentially evaluated expression". Given that,
if we take the cuttings from the standard that you quoted, we have
that there's no way to assign to an unitialized pointer:

int   i,  * pi;
pi = &i;   // pi - an invalid pointer value - is used. Undefined
behavior?


I think the findings are enough for a defect report, because the
sentence "The effect of using an invalid pointer value (including
passint it to a deallocation function) is undefined" is incorrect.


Thank you
Kiril

---
[ 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                ]



