Title
atomics cannot support aggregate initialization
Status
cd1
Section
[atomics.types.generic]
Submitter
Alisdair Meredith

Created on 2008-06-03.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

within the synopsis in [atomics.types.integral] edit as follows.


....
typedef struct atomic_bool {
....
  constexpr explicit atomic_bool(bool);
....
typedef struct atomic_itype {
....
  constexpr explicit atomic_itype(integral);
....

edit [atomics.types.integral] paragraph 2 as follows.

The atomic integral types shall have standard layout. They shall each have a trivial default constructor, a constexpr explicit value constructor, a deleted copy constructor, a deleted copy assignment operator, and a trivial destructor. They shall each support aggregate initialization syntax.

within the synopsis of [atomics.types.address] edit as follows.


....
typedef struct atomic_address {
....
  constexpr explicit atomic_address(void*);
....

edit [atomics.types.address] paragraph 1 as follows.

The type atomic_address shall have standard layout. It shall have a trivial default constructor, a constexpr explicit value constructor, a deleted copy constructor, a deleted copy assignment operator, and a trivial destructor. It shall support aggregate initialization syntax.

within the synopsis of [atomics.types.generic] edit as follows.


....
template <class T> struct atomic {
....
  constexpr explicit atomic(T);
....
template <> struct atomic<integral> : atomic_itype {
....
  constexpr explicit atomic(integral);
....
template <> struct atomic<T*> : atomic_address {
....
  constexpr explicit atomic(T*);
....

edit [atomics.types.generic] paragraph 2 as follows.

Specializations of the atomic template shall have a deleted copy constructor, a deleted copy assignment operator, and a constexpr explicit value constructor.

Date: 2010-10-21.18:28:33

[ San Francisco: ]

The preferred approach to resolving this is to remove the explicit specifiers from the atomic integral type constructors.

Lawrence will provide wording.

This issue is addressed in N2783.

Date: 2010-10-21.18:28:33

[ Jens adds: ]

Note that

atomic_itype a1 = { 5 };

would be aggregate-initialization syntax (now coming under the disguise of brace initialization), but would be ill-formed, because the corresponding constructor for atomic_itype is explicit. This works, though:

atomic_itype a2 { 6 };
Date: 2008-06-03.00:00:00

The atomic classes (and class templates) are required to support aggregate initialization ([atomics.types.integral] p. 2 / [atomics.types.address] p. 1) yet also have user declared constructors, so cannot be aggregates.

This problem might be solved with the introduction of the proposed initialization syntax at Antipolis, but the wording above should be altered. Either strike the sentence as redundant with new syntax, or refer to 'brace initialization'.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg4029
2010-10-21 18:28:33adminsetmessages: + msg4028
2010-10-21 18:28:33adminsetmessages: + msg4027
2008-06-03 00:00:00admincreate