|Target:||SG1, then probably CWG|
It is widely accepted that the current definition of
memory_order_consume in the standard is not useful.
All current compilers essentially map it to
The difficulties appear to stem both from the high implementation complexity,
from the fact that the current definition uses a fairly general definition
of "dependency", thus requiring frequent and inconvenient use of the
kill_dependency call, and from the
frequent need for
Details can be found in e.g.
Nonetheless, it is also widely accepted that
has frequent and important use cases in many large code bases. For example,
the Linux kernel makes extensive use of RCU, which relies on this facility
for weakly ordered architectures like ARM and Power.
Some core Android code similarly relies on dependency-based ordering.
Currently there is no way to express this code in a way that is both performant
Thus SG1 continues to discuss improved, more usable, versions. See
P0190R1 or successors. It is likely that any such revision will not be
fully backwards-compatible with the old one, but will better support
common use cases.
The current expectation is that the replacement facility will rely on
core memory model and atomics definitions very similar to what's currently
memory_order_consume does have a profound impact
on the memory model, removing this text would allow drastic simplification,
but conversely would make it very difficult to add anything along the lines of
memory_order_consume back in later, especially if the standard
evolves in the meantime, as expected. Thus we are not proposing to
remove the current wording.
It is not feasible to move all affected text to Annex D, but there
seem be precedents (e.g. D.2) for defining features in the body of the
standard and declaring them deprecated here. It is also unsafe to
memory_order_consume from the enumeration
type to which it belongs,
since this would change the value of the other enumeration constants.
And we know that there is important code that relies on those, even
aside from ABI issues. Thus we propose the following relatively
Add a new paragraph to Annex D:
It is unclear what to do with the
kill_dependency function and
carries_dependency attribute. My sense is that we will want to
kill_dependency, but that
carries_dependency will probably need to be specified significantly
Carries_dependency is also better isolated from
everything else. Thus I suggest moving only
Move section 7.6.4 [dcl.attr.depend] to Annex D. Add an introductory sentence: