From 5867976317321027250
X-Google-Thread: f78e5,2b20eaff21a1a3c1,start
X-Google-Attributes: gidf78e5,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: oporat@yahoo.com (Ofer Porat)
Newsgroups: comp.std.c++
Subject: Defect Report: new sequencing rules
Date: Sat,  2 Jun 2007 23:42:12 GMT
Lines: 64
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <139194.28017.qm@web30714.mail.mud.yahoo.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.demon.co.uk 1180827744 29551 158.152.254.254 (2 Jun 2007 23:42:24 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sat, 2 Jun 2007 23:42:24 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
  s=s1024; d=yahoo.com;
  h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID;
  b=48zSYas5K9ut7dEUN6HfC0aR0sxLI53baboIuhBZwSUWLeHRgPnYgh0S9u0b8y6eWAReZ3CHPtXIBYcP79Nhu7ehEv6m6rWSvAVlTdBPS7UvDvgWz4tBYCNmtXBrviqAuZCPn9sNulmLY7KXxNzDZvZfJImB8Bcj7VmsRJtWsqg=;
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id l52NgCbE002341;
	Sun, 3 Jun 2007 09:42:12 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-YMail-OSG: mDCrmRwVM1m6HWEFU6RfspLn3m9sD4hxoKAfSV5qcjvA.AEPYrQ9muqYQBm7aEDL2l2e94l25cVGTVLgXeqZx7KLLgN1brddRScpsAawdW6JUJEYDfY-
X-Delivered-To: std-c++@mailman.ucar.edu
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:8766

In "1.9.16 [intro.execution]" of N2284, the following
expression
is still listed as an example of undefined behavior:

i = ++i + 1;

However, it appears that the new sequencing rules make
this
expression well-defined:
a) The assignment side-effect is required to be
sequenced after
the value computations of both its LHS & RHS (5.17.1.)
b) The LHS (i) is an lvalue, so its value computation
involves
computing the address of i.
c) In order to value-compute the RHS (++i + 1), it is
necessary
to first value-compute the lvalue expression "++i" and
then
do an lvalue-to-rvalue conversion on the result.  This
guarantees
that the incrementation side-effect is sequenced
before the
computation of the addition operation, which in turn
is sequenced
before the assignment side effect.  In other words, it
yields
a well-defined order and final value for this
expression.

It should be noted that a similar expression

i = i++ + 1;

is still not well-defined, since the incrementation
side-effect
remains unsequenced with respect to the assignment
side-effect.

It's unclear whether making the expression in the
example well-defined
was intentional or just a coincidental byproduct of
the new
sequencing rules.  In either case either the example
should be fixed,
or the rules should be changed.

Ofer Porat
oporat@yahoo.com



 
____________________________________________________________________________________
Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

---
[ 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.comeaucomputing.com/csc/faq.html                      ]



