From -4148167821887359557
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7522e5259f7267d6
X-Google-Attributes: gidf78e5,public
From: jpotter@falcon.lhup.edu (John Potter)
Subject: Re: x = y = z;  Undefined?
Date: 2000/01/12
Message-ID: <387bc96e.43976982@news.csrlink.net>#1/1
X-Deja-AN: 571439908
X-NNTP-Posting-Host: 209.173.93.86
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <MPG.12ddaa92533ae9679896a6@news.supernews.com> <t7so0bqea7.fsf@calumny.jyacc.com> <3876254a.30903561@news.csrlink.net> <derobert-9FC87E.01591309012000@news.erols.com> <3879ca08.3142429@news.csrlink.net> <derobert-8223E1.23372510012000@news.erols.com> <387b3c32.7816532@news.csrlink.net> <t7d7r8xyxm.fsf@calumny.jyacc.com>
X-UID: 0000000001
X-Status: $$$T
X-Trace: newscene.newscene.com 947638207 209.173.93.86 (Tue, 11 Jan 2000 18:50:07 CST)
Organization: Newscene Public Access Usenet News Service (http://www.newscene.com/)
NNTP-Posting-Date: Tue, 11 Jan 2000 18:50:07 CST
Newsgroups: comp.std.c++
Originator: clamage@taumet


On Wed, 12 Jan 2000 05:43:01 CST, Hyman Rosen <hymie@prolifics.com>
wrote:

: jpotter@falcon.lhup.edu (John Potter) writes:
: > The undefined behavior involves the final value of i1.  The compiler
: > is not required to check for undefined behavior and there is no
: > reason to expect that it does check.  It is required to compute the
: > value 5.  Your code above does not compute the value 5.
: 
: No. If a program execution encounters undefined behavior, the Standard
: imposes no requirements at all on any portion of the execution, before
: or after the undefined behavior is encountered.
: 
: This is explicitly stated in 1.9/5.

Well known rhetoric.  If I write code with undefined behavior,
execute it, and something bad happens by accident, it is my problem.

If you write a compiler which detects the presence of undefined
behavior and purposely generates code to damage my computer, you
are in trouble and the standard will not protect you.

The only way that the mentioned reordering of the instructions is
valid is if the compiler detects the undefined behavior.  Thus, the
reordering is not valid.

James Kanze gave several examples of reasonable code generation
which would work properly in the absence of undefined behavior
and give strange results in the presence of undefined behavior.
That was in clc++m.  I am convinced that a sane compiler can produce
other than expected from the code examples.  That was what I asked
for.

I have no interest in fairy tales about optimizers which take
special actions when undefined behavior code is detected or
nasal daemons or universes ending.

John


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




