From -3823596433365667925
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,6d203f57726a4ad8
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-01-11 09:23:34 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!diablo.theplanet.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: thp@cs.ucr.edu
Newsgroups: comp.std.c++
Subject: Re: Intelligent subscript checking
Date: Sat, 11 Jan 2003 17:23:30 +0000 (UTC)
Organization: University of California, Riverside
Lines: 53
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <avls6r$ssl$1@glue.ucr.edu>
References: <a6150b7f.0212140326.45196cf4@posting.google.com> <3E081F9B.3090409@nycap.rr.com> <d6651fb6.0212300235.6f30cea2@posting.google.com> <fCDW22S7qKE+EwDj@robinton.demon.co.uk> <d6651fb6.0301020346.45b60a60@posting.google.com> <avdrc8$qf2$1@glue.ucr.edu> <26fabedc.0301080212.14b8d54e@posting.google.com> <3E1C87E8.70409@animats.com> <d6651fb6.0301090257.513ebec@posting.google.com> <3E1DEFAF.4020805@animats.com>
X-Trace: mail2news.demon.co.uk 1042305810 22193 10.0.0.1 (11 Jan 2003 17:23:30 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sat, 11 Jan 2003 17:23:30 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.05)
	id 18XPM0-0005lo-00
	for mail2news@news.news.demon.net; Sat, 11 Jan 2003 17:23:28 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id EAA06759; Sun, 12 Jan 2003 04:23:24 +1100 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ncar.ucar.edu
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: Fri, 10 Jan 2003 07:19:55 +0000 (UTC)
X-User-Agent: tin/1.5.14-20020926 ("Soil") (UNIX) (Linux/2.4.20-xfs (i686))
X-Spam-Status: No, hits=-3.7 required=5.0
	tests=INVALID_MSGID,ITS_LEGAL,NOSPAM_INC,NO_REAL_NAME,REFERENCES,
	      SPAM_PHRASE_01_02,USER_AGENT
	version=2.41
Xref: archiver1.google.com comp.std.c++:17009

John Nagle <nagle@animats.com> wrote:
+ James Kanze wrote:
+ 
+> nagle@animats.com (John Nagle) wrote in message
+> news:<3E1C87E8.70409@animats.com>...
+> 
+>>Tom Hyer wrote:
+ 
+>>Right now, it's illegal for the compiler to hoist those asserts out of
+>>the loop, because they'd fail "early".
+>>
+> 
+> Right now, it is perfectly legal for the compiler to hoist those asserts
+> out of the loop, because doing so does not affect the observable
+> behavior of the program.
+ ....
+ 
+ 
+    Unfortunately, no.  Early assertion failure does affect the
+ observable behavior of the program.   Whatever was supposed to
+ happen on the iterations of the loop before the assertion failed
+ won't get to happen if the assert is hoisted out of the loop
+ and fails before the loop is even entered.
+ The compiler doesn't know that assert causes termination and
+ is considered an error condition.

There have been threads here and/or in comp.std.c where members of the
Standards committee(s) seemed to agree and to argue convincingly that,
as soon as undefined behavior becomes proveably inevitable, the
behavior becomes undefined.  Worse yet (the argument goes), when
behavior becomes undefined, among the acceptable behaviors is that of
corrupting buffered output, i.e., which has the apparent effect of
unperforming or reperforming all observable behavior thus far back
through translation time.  So, under a conforming implementation, a
well-formed process that prints out the digits of pi but encounters
undefined behavior on the millionth digit could appear to have a
simple syntax error.

In the case at hand, as soon as exceeding an array bound becomes
inevitable, anything goes including the premature firing of an
assertion.  Admittedly, that behavior can be quite misleading in cases
where the the first thousand iterations of the loop should have
generated output prior to the violation of the assertion.

Tom Payne


---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



