From -4411830454019841002
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,6d203f57726a4ad8
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-01-11 09:25:37 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: kanze@gabi-soft.de (James Kanze)
Newsgroups: comp.std.c++
Subject: Re: Intelligent subscript checking
Date: Sat, 11 Jan 2003 17:25:33 +0000 (UTC)
Organization: http://groups.google.com/
Lines: 42
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <d6651fb6.0301100128.37fdb3a8@posting.google.com>
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> <avjeft$je5$1@glue.ucr.edu>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: mail2news.demon.co.uk 1042305933 22273 10.0.0.1 (11 Jan 2003 17:25:33 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sat, 11 Jan 2003 17:25:33 +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 18XPNv-0005n5-00
	for mail2news@news.news.demon.net; Sat, 11 Jan 2003 17:25:32 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id EAA07176; Sun, 12 Jan 2003 04:25:22 +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: 10 Jan 2003 09:28:34 GMT
X-Spam-Status: No, hits=-8.4 required=5.0
	tests=NOSPAM_INC,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01
	version=2.41
Xref: archiver1.google.com comp.std.c++:17016

thp@cs.ucr.edu wrote in message news:<avjeft$je5$1@glue.ucr.edu>...
> John Nagle <nagle@animats.com> wrote:
> [...]
> + Right now, it's illegal for the compiler to hoist
> + those asserts out of the loop, because they'd fail
> + "early".  

> Hmmmmm.  I had the opposite impression, i.e., I thought that
> conforming implementations are free to do as they please as soon as
> they can ascertain with certainty that undefined behavior is
> inevitable.

It's a bit more complicated than that.  The presence of the assertions
means that there won't be any undefined behavior.

The compiler can (generally) hoist, because if you abort the code in the
assertion, there is no visible difference in the behavior if you abort
it before the loop, or in the loop.

The compiler can (always) generate two loops, one with the assertions,
and one without, and choose which one to use according to whether the
the assertion might trigger or not.

> If hoisting optimization is valid, the assert should only fire if it
> would have fired in the loop, at which point the behavior would have
> become undefined had the assert not been there.

Had the assert not been there.  But it is there.

The whole point of the assert is to eliminate the undefined behavior.

--
James Kanze                           mailto:jkanze@caicheuvreux.com
Conseils en informatique orient�e objet/
                    Beratung in objektorientierter Datenverarbeitung

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



