public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/109536] Failure to compile constexpr std::vector with -D_GLIBCXX_DEBUG
Date: Thu, 14 Dec 2023 16:34:24 +0000	[thread overview]
Message-ID: <bug-109536-4-RAKQ25bTyc@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109536-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:7d00a59229ee17af009a3c6c6208b0611740ed49

commit r14-6553-g7d00a59229ee17af009a3c6c6208b0611740ed49
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Dec 6 13:39:52 2023 +0000

    libstdc++: Make __gnu_debug::vector usable in constant expressions
[PR109536]

    This makes constexpr std::vector (mostly) work in Debug Mode. All safe
    iterator instrumentation and checking is disabled during constant
    evaluation, because it requires mutex locks and calls to non-inline
    functions defined in libstdc++.so. It should be OK to disable the safety
    checks, because most UB should be detected during constant evaluation
    anyway.

    We could try to enable the full checking in constexpr, but it would mean
    wrapping all the non-inline functions like _M_attach with an inline
    _M_constexpr_attach that does the iterator housekeeping inline without
    mutex locks when called for constant evaluation, and calls the
    non-inline function at runtime. That could be done in future if we find
    that we've lost safety or useful checking by disabling the safe
    iterators.

    There are a few test failures in C++20 mode, which I'm unable to
    explain. The _Safe_iterator::operator++() member gives errors for using
    non-constexpr functions during constant evaluation, even though those
    functions are guarded by std::is_constant_evaluated() checks. The same
    code works fine for C++23 and up.

    libstdc++-v3/ChangeLog:

            PR libstdc++/109536
            * include/bits/c++config (__glibcxx_constexpr_assert): Remove
            macro.
            * include/bits/stl_algobase.h (__niter_base, __copy_move_a)
            (__copy_move_backward_a, __fill_a, __fill_n_a, __equal_aux)
            (__lexicographical_compare_aux): Add constexpr to overloads for
            debug mode iterators.
            * include/debug/helper_functions.h (__unsafe): Add constexpr.
            * include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Remove
            macro, folding it into ...
            (_GLIBCXX_DEBUG_VERIFY_AT_F): ... here. Do not use
            __glibcxx_constexpr_assert.
            * include/debug/safe_base.h (_Safe_iterator_base): Add constexpr
            to some member functions. Omit attaching, detaching and checking
            operations during constant evaluation.
            * include/debug/safe_container.h (_Safe_container): Likewise.
            * include/debug/safe_iterator.h (_Safe_iterator): Likewise.
            * include/debug/safe_iterator.tcc (__niter_base, __copy_move_a)
            (__copy_move_backward_a, __fill_a, __fill_n_a, __equal_aux)
            (__lexicographical_compare_aux): Add constexpr.
            * include/debug/vector (_Safe_vector, vector): Add constexpr.
            Omit safe iterator operations during constant evaluation.
            * testsuite/23_containers/vector/bool/capacity/constexpr.cc:
            Remove dg-xfail-if for debug mode.
            * testsuite/23_containers/vector/bool/cmp_c++20.cc: Likewise.
            * testsuite/23_containers/vector/bool/cons/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/bool/element_access/1.cc:
            Likewise.
            * testsuite/23_containers/vector/bool/element_access/constexpr.cc:
            Likewise.
            *
testsuite/23_containers/vector/bool/modifiers/assign/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/bool/modifiers/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/bool/modifiers/swap/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/capacity/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/cmp_c++20.cc: Likewise.
            * testsuite/23_containers/vector/cons/constexpr.cc: Likewise.
            * testsuite/23_containers/vector/data_access/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/element_access/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/modifiers/assign/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/modifiers/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/modifiers/swap/constexpr.cc:
            Likewise.
            * testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
            Adjust dg-error line number.

  parent reply	other threads:[~2023-12-14 16:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 12:43 [Bug libstdc++/109536] New: " terra at gnome dot org
2023-04-17 20:41 ` [Bug libstdc++/109536] " jakub at gcc dot gnu.org
2023-04-17 20:41 ` jakub at gcc dot gnu.org
2023-04-18 11:21 ` redi at gcc dot gnu.org
2023-12-05 23:15 ` redi at gcc dot gnu.org
2023-12-06 14:30 ` redi at gcc dot gnu.org
2023-12-14 16:34 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-14 16:35 ` redi at gcc dot gnu.org
2024-01-18 15:36 ` cvs-commit at gcc dot gnu.org
2024-01-18 16:51 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109536-4-RAKQ25bTyc@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).