This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.
Section: 33.5.8 [atomics.types.generic] Status: Resolved Submitter: BSI Opened: 2010-08-25 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [atomics.types.generic].
View all issues with Resolved status.
Discussion:
Addresses GB-133
The free functions that operate on atomic_address can be used to store a pointer to an unrelated type in an atomic<T*> without a cast. e.g.
int i; atomic<int*> ai(&i); string s; atomic_store(&ai,&s);
Overload the atomic_store, atomic_exchange and atomic_compare_exchange_[weak/strong] operations for atomic<T*> to allow storing only pointers to T.
[ 2010-10-27 Daniel adds: ]
Resolving this issue will also solve 1467
Accepting n3164 would solve this issue by removing atomic_address.
[Resolved in Batavia by accepting n3193. ]
Proposed resolution:
Add the following overloads to 33.5.8 [atomics.types.generic], the synopsis around the specialization atomic<T*>, as indicated:
namespace std { [..] template <class T> struct atomic<T*> : atomic_address { [..] }; template<typename T> void atomic_store(atomic<T*>&,T*); template<typename T> void atomic_store(atomic<T*>&,void*) = delete; template<typename T> void atomic_store_explicit(atomic<T*>&,T*,memory_order); template<typename T> void atomic_store_explicit(atomic<T*>&,void*,memory_order) = delete; template<typename T> T* atomic_exchange(atomic<T*>&,T*); template<typename T> T* atomic_exchange(atomic<T*>&,void*) = delete; template<typename T> T* atomic_exchange_explicit(atomic<T*>&,T*,memory_order); template<typename T> T* atomic_exchange_explicit(atomic<T*>&,void*,memory_order) = delete; template<typename T> T* atomic_compare_exchange_weak(atomic<T*>&,T**,T*); template<typename T> T* atomic_compare_exchange_weak(atomic<T*>&,void**,void*) = delete; template<typename T> T* atomic_compare_exchange_weak_explicit(atomic<T*>&,T**,T*,memory_order); template<typename T> T* atomic_compare_exchange_weak_explicit(atomic<T*>&,void**,void*,memory_order) = delete; template<typename T> T* atomic_compare_exchange_strong(atomic<T*>&,T**,T*); template<typename T> T* atomic_compare_exchange_strong(atomic<T*>&,void**,void*) = delete; template<typename T> T* atomic_compare_exchange_strong_explicit(atomic<T*>&,T**,T*,memory_order); template<typename T> T* atomic_compare_exchange_strong_explicit(atomic<T*>&,void**,void*,memory_order) = delete; }