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