From -5420737059409650167
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,16c102c32134aea8
X-Google-Attributes: gidf78e5,public
From: James Kuyper <kuyper@wizard.net>
Subject: Re: Defect Report: Unnecessary restriction on past-the-end iterators
Date: 2000/02/05
Message-ID: <389A2F56.8B5C9B24@wizard.net>#1/1
X-Deja-AN: 581588178
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <538B4E4235ECD211B35B0090273CC28B012E28@CECEXCHANGE>
X-Accept-Language: en,de,es,ru
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 949686056 mail2news:15813 mail2news mail2news.demon.co.uk
Organization: bCandid - Powering the world's discussions - http://bCandid.com
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Mime-Version: 1.0
Nntp-Posting-Date: Thu, 03 Feb 2000 18:43:14 MST
Newsgroups: comp.std.c++

scleary@jerviswebb.com wrote:
> 
> [Moderator's note: forwarded to C++ Committee. -sdc ]
> 
> Unnecessary restriction on past-the-end iterators
> 
> Section: 24.1 [Iterator requirements]
> Submitter: Stephen Cleary
> Date: 02 February 2000
> 
> In 24.1 [Iterator requirements] paragraph 5, it is stated ". . .
> Dereferenceable and past-the-end values are always non-singular."
> 
> This places an unnecessary restriction on past-the-end iterators for
> containers with forward iterators (for example, a singly-linked list).  If
> the past-the-end value on such a container was a well-known singular value,
> it would still satisfy all forward iterator requirements.

Not really. The only operation that is defined for singular iterator
values is their replacement by non-singular values (see 24.1 p6). In
particular, comparing a singular iterator to another iterator allows
undefined behavior. It's certainly not safe to copy them or assign them.
It would be rather embarrasing to define a container where any operation
user code performed on container.end() necessarily allowed undefined
behavior.

The canonical example of a singular value is not (T*)NULL. That's a
non-singular iterator that happens to also not be dereferencable. The
canonical singular iterator is an unitialized pointer. There are real
machines where loading an address value into an address register causes
that value to be validated. On those machines, loading an uninitialized
pointer can causes immediate termination of your program. This is a
deliberate safety measure: any program which would attempt to use an
uninitialized pointer is (IMO correctly) assumed to be so poorly written
that it can't be safely allowed to run.

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]




