From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5B7FA3858D37; Thu, 18 Jan 2024 15:36:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B7FA3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705592216; bh=AcvPr6Ukurt8yXkdavia1dkjKFuwTJoH/DfSDgjhf8k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XKbrqf0Mx1iqdaQwbBIHa64CW8Rjvx1KS49ciR1QShNDb/MoXOjyqtrmzIl1gQOV7 0kK7tFRwPOyZurZJt3L/MtH+FtTkH3SWFyHGzGE+h9NbXMenaFWNHXgTnCK6l09Ovq V9Yub5li4Jt2/DsK9QnbLg3j8e9ae+m8sZuLMEng= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109536] Failure to compile constexpr std::vector with -D_GLIBCXX_DEBUG Date: Thu, 18 Jan 2024 15:36:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: patch X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109536 --- Comment #7 from GCC Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:3d3145e9e1461e92bef02d55d36990261dd0444d commit r14-8252-g3d3145e9e1461e92bef02d55d36990261dd0444d Author: Patrick Palka 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 fr= om 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=3D): Use them around the code path th= at defines a variable of type __gnu_cxx::__scoped_lock. (_Safe_iterator::operator++): Likewise. (_Safe_iterator::operator--): Likewise. (_Safe_iterator::operator+=3D): Likewise. (_Safe_iterator::operator-=3D): 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 =