Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Unpredictab...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 12 Topic 45818 of 47006
Post > Topic >>

Re: Unpredictable nature of increment operators

by Jerry Coffin <jcoffin@[EMAIL PROTECTED] > May 11, 2008 at 09:05 AM

In article <68nqmmF2u7p59U1@[EMAIL PROTECTED]
>, bop@[EMAIL PROTECTED]
 says...

[ ... ]

> > 1: Though it's open to some question. $1.9/8 says: "Once the
> > execution of a function begins, no expressions from the calling
> > function are evaluated until execution of the called function has
> > completed."
> >
> > I'm interpreting evaluating the arguments to a function as part of
> > execution of the function. If you choose to interpret it as a
> > completely separate act that happens before the function's
> > execution, then you're right -- no ordering is defined. At least in
> > this case, it doesn't make any real difference though -- the
> > overall result is undefined behavior either way.
> 
> I think your second interpretation is the correct one. It means that 
> ++i can be evalueated before or after calling f, but not during.

You could _certainly_ be right. As I said, in this case it doesn't 
really make much difference, since either one gives undefined results.

I got curious and read through N2284, and found that the wording has 
been changed to [intro.execution]/16:

	Every evaluation in the calling function (including other
	function calls) that is not otherwise specifically
	sequenced before or after the execution of the body of
	the called function is indeterminately sequenced with
	respect to the execution of the called function.

This is apparently an attempt at clarifying the situation, but doesn't 
seem (to me) to add much clarity. In particular, it specifically cites 
execution of the body of the function in one place, but execution of the 
called function in the other. It's not at all clear whether this is just 
mildly sloppy wording, and the two are intended to be synonymous, or 
whether it's completely intentional, and intended to delineate between 
the two.

-- 
    Later,
    Jerry.

The universe is a figment of its own imagination.
 




 12 Posts in Topic:
Unpredictable nature of increment operators
bintom <binoythomas110  2008-05-08 17:16:56 
Re: Unpredictable nature of increment operators
Ian Collins <ian-news@  2008-05-09 12:17:58 
Re: Unpredictable nature of increment operators
Martin York <Martin.Yo  2008-05-09 10:11:08 
Re: Unpredictable nature of increment operators
"Victor Bazarov"  2008-05-09 13:21:26 
Re: Unpredictable nature of increment operators
Jerry Coffin <jcoffin@  2008-05-10 08:47:59 
Re: Unpredictable nature of increment operators
James Kanze <james.kan  2008-05-10 07:08:42 
Re: Unpredictable nature of increment operators
Jerry Coffin <jcoffin@  2008-05-10 09:01:10 
Re: Unpredictable nature of increment operators
"Bo Persson" &l  2008-05-11 10:56:59 
Re: Unpredictable nature of increment operators
Jerry Coffin <jcoffin@  2008-05-11 09:05:09 
Re: Unpredictable nature of increment operators
Old Wolf <oldwolf@[EMA  2008-05-11 02:14:44 
Re: Unpredictable nature of increment operators
James Kanze <james.kan  2008-05-11 09:09:34 
Re: Unpredictable nature of increment operators
James Kanze <james.kan  2008-05-11 09:19:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 1:58:54 CDT 2008.