Frederick Gotham wrote:
Quote:
The Standard says that the behaviour is unspecified with regard to the
order of evaluation in the following:
>
int FuncA();
int FuncB();
>
int main()
{
FuncA() + FuncB();
}
>
FuncA might be called first, or then again it might be FuncB. Does the
Standard place any restriction on the two of them running at the same time
(e.g. if there are two CPU's or whatever)?
Yes. Whichever function is called first, once execution of that
function begins no other code in main is executed until that function
returns.
Quote:
Is the behaviour of the following snippet undefined because of a sequence
point violation? (Again, I'm unsure as to whether the implementation may
run them concurrently.)
>
int i = 5;
>
int FuncA() { return ++i; }
>
int FuncB() { return ++i; }
>
int main()
{
FuncA() + FuncB();
}
No undefined behaviour there. The calls to FuncA and FuncB can not be
interleaved.
Quote:
If there were a requirement that either FuncA or FuncB must be executed on
its own prior to invocation of the second function, then it would seem that
there would be no problem -- a problem would only arise if they were
executed concurrently.
Correct.
Caveat: In answering your question I have not referred directly to the
standard. I have referred to Herb Sutter.
http://www.gotw.ca/gotw/056.htm
<snip>
Gavin Deane