Title
Does atomic_compare_exchange_* accept v == nullptr arguments?
Status
c++14
Section
[depr.util.smartptr.shared.atomic]
Submitter
Howard Hinnant

Created on 2012-07-28.00:00:00 last changed 131 months ago

Messages

Date: 2013-04-19.22:22:17

Proposed resolution:

This wording is relative to N3376.

Change [util.smartptr.shared.atomic] as indicated:

template<class T>
  bool atomic_compare_exchange_weak(
    shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);

-27- Requires: p shall not be null and v shall not be null.

[…]

template<class T>
  bool atomic_compare_exchange_weak_explicit(
    shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
    memory_order success, memory_order failure);
template<class T>
  bool atomic_compare_exchange_strong_explicit(
    shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
    memory_order success, memory_order failure);

-31- Requires: p shall not be null and v shall not be null.

[…]

Date: 2013-04-20.00:00:00

[ 2013-04-20 Bristol ]

Date: 2012-10-19.07:50:57

[ 2012-10 Portland: Move to Ready ]

This is clearly the right thing to do, and Lawrence concurs.

Date: 2012-07-28.00:00:00

Looking at [util.smartptr.shared.atomic]/p31

template<class T>
  bool
  atomic_compare_exchange_strong_explicit(shared_ptr<T>* p,
                                          shared_ptr<T>* v,
                                          shared_ptr<T> w,
                                          memory_order success, memory_order failure);

-31- Requires: p shall not be null.

What about v? Can it be null? And if so, what happens?

This looks closely related to C++11 issue LWG 1030, where we gave every signature in this section a:

Requires: p shall not be null.

It looks like a simple oversight to me that we did not add for the atomic_compare_exchange_*:

Requires: p shall not be null and v shall not be null.

History
Date User Action Args
2014-02-20 13:20:35adminsetstatus: wp -> c++14
2013-04-25 19:07:07adminsetstatus: voting -> wp
2013-04-19 22:22:17adminsetmessages: + msg6477
2013-04-19 22:22:17adminsetstatus: ready -> voting
2012-10-19 07:50:57adminsetmessages: + msg6189
2012-10-19 07:50:57adminsetstatus: new -> ready
2012-08-11 20:23:11adminsetmessages: + msg6113
2012-07-28 00:00:00admincreate