Title
Ambiguous value assignment to atomic_bool
Status
resolved
Section
[atomics.types.integral]
Submitter
BSI

Created on 2010-08-25.00:00:00 last changed 171 months ago

Messages

Date: 2011-05-21.21:15:19

Proposed resolution:

Solved by n3193.

Date: 2010-11-18.12:46:23

[ 2010 Batavia ]

Resolved by adoption of n3193.

Date: 2010-10-27.00:00:00

[ 2010-10-27 Daniel adds: ]

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

Date: 2010-11-13.13:49:23

[ Proposed resolution as of NB comment: ]

Change [atomics.types.integral] as indicated:

namespace std {
  typedef struct atomic_bool {
    [..]
    bool operator=(bool) volatile;
    bool operator=(bool);
  } atomic_bool;
  [..]
}
Date: 2010-11-07.14:07:22

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
History
Date User Action Args
2010-11-18 12:46:23adminsetmessages: + msg5385
2010-11-18 12:46:23adminsetmessages: + msg5384
2010-11-18 12:46:23adminsetstatus: nad editorial -> resolved
2010-11-13 13:49:23adminsetstatus: open -> nad editorial
2010-10-27 20:02:48adminsetmessages: + msg5161
2010-10-27 20:02:48adminsetmessages: + msg5160
2010-08-25 00:00:00admincreate