atomic_fetch
operations and "address types"Authors: Joseph Myers
Date: 2025-03-07
Submitted against: C23
Status: Open
C23 7.17.7.6 (The atomic_fetch
and modify generic functions) says:
All these operations are applicable to an object of any atomic integer type other than
_Atomic bool
,atomic_bool
, or the atomic version of an enumeration with underlying typebool
.
and then later says:
For address types, the result may be an undefined address, but the operations otherwise have no undefined behavior.
The effect seems to be confused about whether pointer types should be included or not; the first quoted sentence clearly does not include them, but the second one seems to envisage that they might be included. It also has further problems:
Making the minimal change of removing the second quoted sentence, as suggested in C23 CD1 comment GB-196, did not receive consensus, but the wording is still defective in its present state so some change is needed to address that (either allowing pointer types and adjusting the wording to avoid using terminology that is not defined, or removing the problematic sentence if only integer types are to be allowed). A larger set of changes, mixing both normative and non-normative changes but including changes to allow pointer types here, was in N2389, which was discussed in Ithaca, October 2019.
Given the previous lack of consensus, no specific wording change is proposed here; committee direction would be needed before proposing specific changes to address this issue.
Comment from Issues list maintainer on 2025-06-27:
N3542 proposes changes that would address this issue.