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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:3d3145e9e1461e92bef02d55d36990261dd0444d

commit r14-8252-g3d3145e9e1461e92bef02d55d36990261dd0444d
Author: Patrick Palka <ppa...@redhat.com>
Date:   Thu Jan 18 10:36:07 2024 -0500

    libstdc++/debug: Fix constexpr _Safe_iterator in C++20 mode [PR109536]

    Some _Safe_iterator member functions define a variable of non-literal
    type __gnu_cxx::__scoped_lock, which automatically disqualifies them from
    being constexpr in C++20 mode even if that code path is never constant
    evaluated.  This restriction was lifted by P2242R3 for C++23, but we
    need to work around it in C++20 mode.  To that end this patch defines
    a pair of macros that encapsulate the lambda-based workaround mentioned
    in that paper and uses it to make these functions valid C++20 constexpr
    functions.  The augmented std::vector test element_access/constexpr.cc
    now successfully compiles in C++20 mode with -D_GLIBCXX_DEBUG (and it
    should test all member functions modified by this patch).

            PR libstdc++/109536

    libstdc++-v3/ChangeLog:

            * include/debug/safe_base.h (_Safe_sequence_base::_M_swap):
            Remove _GLIBCXX20_CONSTEXPR from non-inline member function.
            * include/debug/safe_iterator.h
            (_GLIBCXX20_CONSTEXPR_NON_LITERAL_SCOPE_BEGIN): Define.
            (_GLIBCXX20_CONSTEXPR_NON_LITERAL_SCOPE_END): Define.
            (_Safe_iterator::operator=): Use them around the code path that
            defines a variable of type __gnu_cxx::__scoped_lock.
            (_Safe_iterator::operator++): Likewise.
            (_Safe_iterator::operator--): Likewise.
            (_Safe_iterator::operator+=): Likewise.
            (_Safe_iterator::operator-=): Likewise.
            * testsuite/23_containers/vector/element_access/constexpr.cc
            (test_iterators): Test more iterator operations.
            * testsuite/23_containers/vector/bool/element_access/constexpr.cc
            (test_iterators): Likewise.
            * testsuite/std/ranges/adaptors/all.cc (test08) [_GLIBCXX_DEBUG]:
            Remove.

    Reviewed-by: Jonathan Wakely <jwak...@redhat.com>
  • [Bug libstdc++/109536] Failure ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to