Title
Cannot compare_exchange empty pointers
Status
c++20
Section
[depr.util.smartptr.shared.atomic]
Submitter
Alisdair Meredith

Created on 2017-06-15.00:00:00 last changed 38 months ago

Messages

Date: 2017-06-26.20:04:47

Proposed resolution:

This wording is relative to N4659.

  1. Edit [util.smartptr.shared.atomic] as indicated:

    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);
    

    […]

    -35- Remarks: Two shared_ptr objects are equivalent if they store the same pointer value and share ownership, or if they store the same pointer value and both are empty. The weak form may fail spuriously. See 32.6.1.

Date: 2017-06-26.00:00:00

[ 2017-06-26 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

Date: 2017-06-15.19:55:46

[util.smartptr.shared.atomic] p35 states that two shared pointers are equivalent if they store the same pointer value, and share ownership. As empty shared pointers never share ownership, it is not possible to replace an empty shared pointer using the atomic compare_exchange API.

Note that through aliasing, empty shared pointers may still point to different objects, and any resolution must allow for that case too.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2017-11-13 19:01:36adminsetstatus: voting -> wp
2017-10-17 18:34:55adminsetstatus: ready -> voting
2017-06-26 20:04:47adminsetmessages: + msg9293
2017-06-26 20:04:47adminsetstatus: new -> ready
2017-06-15 17:17:31adminsetmessages: + msg9267
2017-06-15 00:00:00admincreate