-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[intro.races] Make reading atomic objects nondeterministic #6501
[intro.races] Make reading atomic objects nondeterministic #6501
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is an editorial clarification of what was already normatively specified; "some" meaning (in English) a (possibly random) pick.
471804c
to
82a5c3b
Compare
I suppose this calls for a wider audit whether every instance of non-deterministic behaviour is marked by the presence of the term "unspecified". |
As the behavior is changed to "unspecified", does it mean the following example is unspecified? std::atomic<int> v{0};
auto c = [](){v.store(1,std::memory_order::release); return 1;}();
auto c2 = [](){v.store(2,std::memory_order::release); return 2;}();
int main(){
auto r = v.load(std::memory_order::acquire); // #1
} Does it mean |
@xmh0511: this edit wasn't meant to change anything, only to clarify. I don't think the wording means "the value is free to be any of the previously assigned values"; rather, it bounds the set of possible values: the wording guarantees that the value that you read is one of the values that was previously written, as opposed to being any other, arbitrary value. |
Well, I think the above example is based on I have correctly read the intent of the wording. So, I asked, Is the result either |
The value is |
Where is the rule that guarantees the result is |
Immediately after the changed paragraph, in the coherence rules. In your example, c1 happens before c2, and c2 happens before the read. If the modifications do not happen before the read, then which modification is visible is unspecified. That doesn't apply in your example though. |
However, [basic.start.dynamic] says
Either reading the value of |
The rule has not changed. It has just been clarified. As @jwakely said, the value of |
The previous wording "some side effect" didn't say which one either. Because it's stated elsewhere, not in that sentence. |
Well, I know p14 only places some limit on the value of r. However, [intro.races] p15, [intro.races] p16, [intro.races] p17, and [intro.races] p18 does not prevent |
I have listed all relevant rules in the above comment, I think they do not prevent |
[intro.abstract]/3:
Without «unspecified» in [intro.race]/14
reading atomic objects is not nondeterministic