https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115402

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tomasz Kaminski <[email protected]>:

https://gcc.gnu.org/g:90dde804626f1344f0d63827709406b135433272

commit r16-4349-g90dde804626f1344f0d63827709406b135433272
Author: Giuseppe D'Angelo <[email protected]>
Date:   Mon Dec 9 01:32:27 2024 +0100

    libstdc++: Handle cv-qualified types in atomic and atomic_ref [PR115402]

    Implements P3233R1 (DR for C++20/C++11, fixes LWG 4069 and 3508).

    This commit implements std::atomic_ref<cv T> support (LWG3508) as DR for
    C++20, by  extractingparts of the __atomic_ref class (that atomic_ref
inherits
    from) into a further base class (__atomic_ref_base):

    * __atomic_ref_base<const T> implements non-mutating (const) atomic API.
      Single base class is used, and the difference in is_always_lock_free and
      required_aligment values between types are handled by
_S_is_always_lock_free,
      _S_required_aligment helper functions.
    * __atomic_ref_base<T> implements the common atomic APIs. The non-mutating
      operations are handled by inherting from __atomic_ref_base<const T>
partial
      partial specialization. Tu support that __atomic_ref_base<const T> stores
      mutable pointer to T, and performs const_cast in constructor.
    * __atomic_ref<T, ....> inherits from __atomic_ref_base<T>, and implement
      type-specific mutable APIs (fetch_add, -=, ...) and difference_type
member
      type.
    * __atomic_ref<const T, ...> inherits from __atomic_ref_base<const T>
      and adds different_type member, whose presence and denoted type depends
      on T.

    The __atomic_ref specialization selection is adjusted to handle
cv-qualified
    bool (add remove_cv_t) and pointer types. To handle the later, additional
    constant template parameter is introduced.

    The atomic wait and notify operations are currently not supported for
volatile
    types, to signal that static assert is added to corresponding methods of
    atomic_ref.

    At the same time,  disable support for cv-qualified types in std::atomic
    (for instance, std::atomic<volatile T> isn't meaningful; one should use
    volatile std::atomic<T>), again as per the paper, resolving LWG4069 as DR
    for C++11. This only affects atomic<volatile T>, as specialization
    atomic with const-qualifed types was already producing an compile-time
    error.

            PR libstdc++/115402

    libstdc++-v3/ChangeLog:

            * include/bits/atomic_base.h (__atomic_ref_base<const _Tp>)
            (__atomic_ref_base<_Tp>): Define by extracting common methods
            from atomic_ref specializations.
            (__atomic_ref<_Tp, In, Fp, Pt>): Inherit from __atomic_ref_base
            and remove extracted method.
            (__atomic_ref<const _Tp, In, Fp, Pt>): Define.
            * include/std/atomic (std::atomic): Added an
            * testsuite/29_atomics/atomic/requirements/types_neg.cc:
            Add test for volatile qualified types.
            * testsuite/29_atomics/atomic_ref/bool.cc: Move the content
            to op_support.cc, add test for bool.
            * testsuite/29_atomics/atomic_ref/op_support.cc: New test
            expanded from atomic_ref/bool.cc.
            * testsuite/29_atomics/atomic_ref/cv_qual.cc: New test.
            * testsuite/29_atomics/atomic_ref/requirements_neg.cc: New test.
            * testsuite/29_atomics/atomic_ref/deduction.cc: Add tests for
            cv-qualified types.
            * testsuite/29_atomics/atomic_ref/float.cc: Likewise.
            * testsuite/29_atomics/atomic_ref/generic.cc: Likewise.
            * testsuite/29_atomics/atomic_ref/integral.cc: Likewise.
            * testsuite/29_atomics/atomic_ref/pointer.cc: Likewise.
            * testsuite/29_atomics/atomic_ref/requirements.cc: Likewise.
            * testsuite/29_atomics/atomic_ref/wait_notify.cc: Add tests for
            const qualified types.

    Reviewed-by: Jonathan Wakely <[email protected]>
    Co-authored-by: Tomasz KamiÅski <[email protected]>
    Signed-off-by: Giuseppe D'Angelo <[email protected]>
    Signed-off-by: Tomasz KamiÅski <[email protected]>

Reply via email to