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.

1462. Ambiguous value assignment to atomic_bool

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

Priority: Not Prioritized

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

View all issues with Resolved status.

Duplicate of: 1463

Discussion:

Addresses GB-132, US-157

The atomic_itype types and atomic_address have two overloads of operator=; one is volatile qualified, and the other is not. atomic_bool only has the volatile qualified version:

bool operator=(bool) volatile;

On a non-volatile-qualified object this is ambiguous with the deleted copy-assignment operator

atomic_bool& operator=(atomic_bool const&) = delete;

due to the need for a single standard conversion in each case when assigning a bool to an atomic_bool as in:

atomic_bool b;
b = true;

The conversions are:

atomic_bool& → atomic_bool volatile&

vs

bool → atomic_bool

[ Proposed resolution as of NB comment: ]

Change 99 [atomics.types.integral] as indicated:

namespace std {
  typedef struct atomic_bool {
    [..]
    bool operator=(bool) volatile;
    bool operator=(bool);
  } atomic_bool;
  [..]
}

[ 2010-10-27 Daniel adds: ]

Accepting n3164 would solve this issue by replacing atomic_bool by atomic<bool>.

[ 2010 Batavia ]

Resolved by adoption of n3193.

Proposed resolution:

Solved by n3193.