This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-05-06


2654. Un-deprecation of compound volatile assignments

Section: 7.6.19  [expr.ass]     Status: C++23     Submitter: US     Date: 2022-11-03     Liaison: EWG

P2720R0 comment US 16-045

[Accepted as a DR at the November, 2022 meeting.]

Many functions of volatile were deprecated in C++20. In C++23, volatile compound operations were de-deprecated by P2327. The rationale for this de-deprecation is lacking.

Deprecation is not removal. P2327 in C++23 is stopping the change that we began with C++20, mere moments ago if counting by adoption time. It primarily argued that it's an inconvenient change, and that some of the audience would just not cooperate with WG21's indicated direction, so WG21 should compromise the technical consistency of the Standard so they could continue to not cooperate.

The paper did not bring new information on the technical merits of the case, and net the result of applying it was a technically dissonant Standard specification --- a strictly worse specification than C++20. Bitwise compound operations are not special for any technical reason, they are only special because making them special shields some from deprecation diagnostics.

EWG 2022-11-07

Contrary to the direction desired in the NB comment, EWG resolved to un-deprecate all volatile compound assignments.

Proposed resolution (approved by CWG 2022-11-08):

Change in 7.6.19 [expr.ass] paragraph 6 as follows:

The behavior of an expression of the form E1 op= E2 is equivalent to E1 = E1 op E2 except that E1 is evaluated only once. [ Note: The object designated by E1 is accessed twice. -- end note ] Such expressions are deprecated if E1 has volatile-qualified type and op is not one of the bitwise operators |, &, ^; see D.5.

Change in D.4 [depr.volatile.type] paragraph 2 as follows:

  brachiosaur += neck;                // deprecatedOK
  brachiosaur = brachiosaur + neck;   // OK
  brachiosaur |= neck;                // OK, bitwise compound expression