From 6349321320574440824
X-Google-Thread: f78e5,174aa7b34b06a51,start
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 21 Nov 2005 23:30:32 -0600
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
From: pongba@gmail.com
Newsgroups: comp.std.c++
Subject: Is this really unspecified behavior?
Organization: http://groups.google.com
Message-ID: <1132629737.664847.151630@o13g2000cwo.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: o13g2000cwo.googlegroups.com; posting-host=222.94.28.3;
   posting-account=t_ay-g0AAADpcfWwZ2b8zZ89gVs9u18v
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Mon, 21 Nov 2005 23:20:16 CST
Lines: 48
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-7PyTMtyXtblJOPR5D8vEFBEDFNet4aIcHaepA4L3DkM1itprW1T5ThS2jvHKytNBYqnG/bNTFlAT2un!0dLtuv7dgykWJAd4DS8ovN63l9KO0mkGVZkfD07JiR+xdm8Arm40Pm/1g2AlZNLEo/2brJ8f6vdC!tWXnnCbH271otHDT54gCnEkSOghZrKZ7ejIRAO+GhMg=
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news1.google.com comp.std.c++:2574

C++03 5/4:
[Example:
i = v[i++]; // the behavior is unspecified
.
]

I wanna ask that if v is a std::vector which overloads operator[], is
this unspecified any more?

What I understand is that there's a sequence point at the entry and
exit of a function call, well, operator function certainly is a
function, so if we change that 'v' to a object of std::vector, v[i++]
becomes a function call, the side effect of which takes place before
the assignment operation, therefore 'i' gets a determinable value,
which is v[*old value of the i*], which of course is not unspecified.

That said, I wonder if this analysis is right, did I miss or
misunderstand anything?
If that is true, is this an evidence that some inconsistency, in some
extremely non-obvious way, exists between build-in operator and
operator function(informally known as 'overloaded operator').

Another question is:

What is the side-effect of 'i++' actually? Two options, first of which
is "fetch i from memory, add it by 1, write the new value back", second
is "write the new value stored previously somewhere into the storage of
'i'". Is the answer 'both' or 'either' or whatever? Plus, the words
below(also excerpted from [c++03;5/4])are really puzzling to me, can
anyone explain it please? Does it have anything to do with the two
questions I asked?

[C++03;5/4]"Between the previous and next sequence point a scalar
object shall have its stored value modified at most once by the
evaluation of an expression. Furthermore, the prior value shall be
accessed only to determine the value to be stored.The requirements of
this paragraph shall be met for each allowable ordering of the
subexpressions of a full expression; otherwise the behavior is
undefined."

Any help is appreciated;-)

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



