cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[atomics] Is the read-modify-write operation a single indivisible operation? #447

Closed xmh0511 closed 11 months ago

xmh0511 commented 11 months ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

As mentioned in this SO question https://stackoverflow.com/questions/65568185/for-purposes-of-ordering-is-atomic-read-modify-write-one-operation-or-two

It is unclear whether read-modify-write is a single operation or three operations implied by its name. As discussed in that question, certain people think read-modify-write comprises two operations, and certain people think it is a single operation, however, it is not explicitly specified in the document

[atomics.order] p10 says

Atomic read-modify-write operations shall always read the last value (in the modification order) written before the write associated with the read-modify-write operation.

Note the emphasized wording, read and write seem to imply that a read-modify-write operation comprises two operations: read and write.

Suggested Resolution

Accurately define the read-modify-write operation

t3nsor commented 11 months ago

Can you explain the normative implications of the issue that you believe exists?

jensmaurer commented 11 months ago

The concern you have is about a library clause, and was already filed as a library isuse: LWG3980

xmh0511 commented 11 months ago

The concern you have is about a library clause, and was already filed as a library isuse: LWG3980

I think they are different issues.

t3nsor commented 11 months ago

But you haven't really explained the issue.