working draft C++, program model

W

wolf.lammen

Hi,

I had a look at the program model of the current working draft of C++
and stumbled over a phrase, that looks to me incorrect.

The first note in 1.10 paragraph 12 states:
"Note: If there is ambiguity about which side effect to a non-atomic
object is visible, then there is a data race, and the behavior is
undefined."

That's not exact, because two unsequenced side effects may cause an
ambiguity
as well.

Consider the following code snippet

int i = 0;
i = // side effect A
i++ // side effect B
+ 1;
if (i == 1)... // value computation C

Since the A and B are unsequenced, both are visible side effects to C.
But this ambiguity does not constitute a data race, because A, B, C
are
executed in the same thread.

----

1.9 paragraph 16 states

"...If a side effect on a scalar object is *unsequenced* to either
another
side effect on the same object, or a value computation using the value
of
the same object, the behavior is undefined."

Is there a reason, why *independently sequenced* side effects do not
constitute undefined behavior?

Wolf Lammen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top