From -6618322605993293655
X-Google-Thread: f78e5,174aa7b34b06a51
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed.vmunix.org!newsfeed.stueberl.de!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: ben-public-nospam@decadentplace.org.uk (Ben Hutchings)
Newsgroups: comp.std.c++
Subject: Re: Is this really unspecified behavior?
Date: Wed, 30 Nov 2005 15:06:48 GMT
Lines: 48
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <slrndore0g.kul.ben-public-nospam@decadentplace.org.uk>
References: <1132629737.664847.151630@o13g2000cwo.googlegroups.com> <1132722639.345095.296070@f14g2000cwb.googlegroups.com> <200511231401.jANE1BuC092897@horus.isnic.is> <hj1hf.4529$N45.2609@newsread1.news.atl.earthlink.net> <37hco1hvfg2s43q2dv3003her7im99airg@4ax.com> <uk6eun0ad.fsf@boost-consulting.com> <1twif.776$iZ3.758@trndny03> <1133189252.960738.262510@g44g2000cwa.googlegroups.com> <1133276211.452281.106150@f14g2000cwb.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1133363213 4883 158.152.254.254 (30 Nov 2005 15:06:53 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 30 Nov 2005 15:06:53 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: slrn/0.9.8.1 (Debian)
X-Orig-X-Trace: individual.net 3mwmdlX3t9sbr8fS7lweuwjRh3UwC4vAgIh4J125O1++4AVcI=
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
X-Reply-To: Ben Hutchings <ben@decadentplace.org.uk>
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id jAUF6mPg015355;
	Thu, 1 Dec 2005 02:06:48 +1100 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Orig-Path: decadentplace.org.uk!news
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:2635

Sandor  Hojtsy <sandor.hojtsy@gmail.com> wrote:
> You keep quoting the standard:
>   i = v[i++];                     // the behavior is unspecified
>   i = 7, i++, i++;                // i becomes 9
>   i = ++i + 1;                    // the behavior is unspecified
>   i = i + 1;                      // the value of i is incremented
> Note that this contains an identified defect, it should correctly read:
> i = v[i++];                     //  the behavior is undefined
> i = 7, i++, i++;                //   i  becomes  9
> i = ++i + 1;                    //  the behavior is undefined
> i = i + 1;                      //  the value of  i  is incremented
> See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#351
>
> I have a question: are these expressions undefined, or well-formed?

They're all well-formed; that's a syntactical property.

> i = i = 1;

Despite the lack of a sequence point I believe this may be defined due
to this wording in 5.17/1: "The result of the assignment operation is
the value stored in the left operand *after* the assignment has taken
place..." (my emphasis).

> i = ++i;
> a = (i = 1) + (i = 1);

In these cases, the order of the two modifications of i is undefined,
so they fall foul of 5/4.

> If I take the standard word by word, they do not modify the value of i
> twice in an expression, because one of the assignments is not
> modification - just reassigning the existing value.

All built-in assignment operators are considered to modify their left
hand side, whether its value changes or not.

-- 
Ben Hutchings
Horngren's Observation:
                   Among economists, the real world is often a special case.

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



