On May 11, 3:01 am, Jerry Coffin <jcof...@[EMAIL PROTECTED]
> wrote:
> > On 9 mai, 19:21, "Victor Bazarov" <v.Abaza...@[EMAIL PROTECTED]
> wrote:
> > > For example, it's not undefined behaviour to do
> > > > f(i++) + ++i;
>
> I believe the compiler is required to treat evaluation of a
> function argument and calling the function as atomic -- i.e. once the
> evaluation of any argument takes place, it must proceed to evaluated the
> other arguments (if any) and then call the function.
There is no such requirement. In the following code,
for example,:
foo( bar(), baz() ) + qux();
the order of calling functions could be:
baz, qux, bar, foo.
or any other ordering, so long as 'foo' comes after
both 'bar' and 'baz'.
The code of Victor Bazarov causes undefined behaviour
if 'i' is a builtin type, because there might not be
a sequence point between the two modifications of 'i'.


|