Created on 2025-01-16.00:00:00 last changed 3 days ago
Proposed resolution:
This wording is relative to N5001.
Modify [atomics.types.pointer] as indicated:
-1- There is a partial specialization of the `atomic` class template for
pointerspointer-to-object types. Specializations of this partial specialization are standard-layout structs. They each have a trivial destructor.
[ 2025-02-07; Reflector poll: NAD ]
The `fetch_OP` members have "Mandates: `T` is a complete object type." and a note explaining that this means arithmetic on `void*` is ill-formed. So implementations are expected to use the partial specialization for `void*` but to reject attempts at arithmetic. They all do this correctly today.
[atomics.types.pointer] p1 states (emphasis mine):
There is a partial specialization of the `atomic` class template for pointers.
which requires atomic<void*> to use the `atomic` class template for pointers. However, the `fetch_add`/`_sub` member functions add a `difference_type` to a `T*` which requires a pointer-to-object type (these member functions are `constexpr`, so trying to support this seems unimplementable).
For `atomic_ref`, the [atomics.ref.pointer] p1 states (emphasis mine):There are specializations of the `atomic_ref`` class template for all pointer-to-object types.
which avoids this issue and applying the same form to [atomics.types.pointer] would make atomic<void*> and atomic_ref<void*> consistent.
Technically this would be a breaking change, but all C++ standard library implementations surveyed are broken, and the proposed fix would make them compliant: see libstdc++, libc++ and MSVC STL errors here. These standard libraries require a pointer-to-object type, atomic<void*> uses the general template. Therefore, no user code seems to be impacted.History | |||
---|---|---|---|
Date | User | Action | Args |
2025-02-07 16:46:48 | admin | set | messages: + msg14583 |
2025-02-07 16:46:48 | admin | set | status: new -> nad |
2025-01-19 09:24:06 | admin | set | messages: + msg14544 |
2025-01-16 00:00:00 | admin | create |