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.

### 1467. Deriving `atomic<T*>` from `atomic_address` breaks type safety

Section: 99 [atomics.types.address] Status: Resolved Submitter: INCITS Opened: 2010-08-25 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [atomics.types.address].

View all issues with Resolved status.

Discussion:

Addresses US-163

Requiring `atomic<T*>` to be derived from `atomic_address` breaks type safety:

>     atomic<double*> ip;
>     char ch;
>     atomic_store(&ip, &ch);
>     *ip.load() = 3.14159;

The last line overwrites `ch` with a value of type `double`.

[ 2010-10-27 Daniel adds: ]

> Resolving this issue will also solve 1469

> Accepting n3164 would solve this issue by removing `atomic_address`.

[ Resolved in Batavia by accepting n3193. ]

Proposed resolution:

1. Change 33.5.8 [atomics.types.generic], class template specialization `atomic<T*>` synopsis, as indicated:

   >     namespace std {
   >       template <class T> struct atomic<T*> : atomic_address {
   >         [..]
   >       };
   >       [..]
   >     }

2. Change 33.5.8 [atomics.types.generic] p. 4 as indicated:

   > 4 There are pointer partial specializations on the `atomic` class template. These specializations shall be publicly derived from `atomic_address`. The unit of addition/subtraction for these specializations shall be the size of the referenced type. These specializations shall have trivial default constructors and trivial destructors.