Title
Should compare_exchange be allowed to modify the expected value on success?
Status
nad
Section
[atomics.types.operations]
Submitter
Jonathan Wakely

Created on 2021-09-29.00:00:00 last changed 27 months ago

Messages

Date: 2022-08-23.00:00:00

[ 2022-08-23 Status changed: Tentatively NAD → NAD. ]

Date: 2022-07-15.00:00:00

[ 2022-07-14; Move to "Tentatively NAD" following reflector poll ]

Date: 2022-07-15.00:00:00

[ 2022-07-06; Move to "Open" following SG1 feedback ]

Allow compare_exchange to modify the expected value on success?

SFFNASA
00054

Date: 2021-10-15.00:00:00

[ 2021-10-14; Reflector poll ]

Set priority to 2 after reflector poll. Send to SG1.

This is 2426 again, but the new requirement to clear padding bits changes things.

Date: 2021-09-29.00:00:00

Currently a compare_exchange will only update the expected parameter if the compare_exchange fails. This precludes unconditionally clearing the padding bits of the expected object prior to doing the compare_exchange, which complicates the implementation by requiring additional work (e.g. making a copy of the expected value and clearing the copy's padding, then copying it back to expected only if the compare_exchange fails).

We should consider whether we want to allow modifications to expected in the success case, if such modifications only affect padding bits (i.e. do not alter the value). If we want to allow it, we need to say so explicitly. The current wording does not permit modifications in the success case, and any such modification could create a data race if another thread is reading the same memory location (if it knows a priori that a compare_exchange_strong would succeed and so not write to that location).

History
Date User Action Args
2022-08-23 13:55:25adminsetmessages: + msg12680
2022-07-14 11:37:55adminsetmessages: + msg12580
2022-07-14 11:37:55adminsetstatus: open -> nad
2022-07-06 16:28:38adminsetmessages: + msg12554
2021-10-14 11:35:22adminsetmessages: + msg12146
2021-10-14 11:35:22adminsetstatus: new -> open
2021-09-29 00:00:00admincreate