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++/112882] [14 Regression] std::clamp no longer usable in header only mode
Date: Thu, 07 Dec 2023 20:55:45 +0000	[thread overview]
Message-ID: <bug-112882-4-g6oUPybVCv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112882-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 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:1395c573c523762957bde8c2a08832c5f4350815

commit r14-6291-g1395c573c523762957bde8c2a08832c5f4350815
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Dec 6 17:21:29 2023 +0000

    libstdc++: Fix recent changes to __glibcxx_assert [PR112882]

    The changes in r14-6198-g5e8a30d8b8f4d7 were broken, as I used
    _GLIBCXX17_CONSTEXPR for the 'if _GLIBCXX17_CONSTEXPR (true)' condition,
    forgetting that it would also be used for the is_constant_evaluated()
    check. Using 'if constexpr (std::is_constant_evaluated())' is a bug.

    Additionally, relying on __glibcxx_assert_fail to give a "not a constant
    expression" error is a problem because at -O0 an undefined reference to
    __glibcxx_assert_fail is present in the compiled code. This means you
    can't use libstdc++ headers without also linking to libstdc++ for the
    symbol definition.

    This fix rewrites the __glibcxx_assert macro again. This still avoids
    doing the duplicate checks, once for constexpr and once at runtime (if
    _GLIBCXX_ASSERTIONS is defined). When _GLIBCXX_ASSERTIONS is defined we
    still rely on __glibcxx_assert_fail to give a "not a constant
    expression" error during constant evaluation (because when assertions
    are defined it's not a problem to emit a reference to the symbol). But
    when that macro is not defined, we use a new inline (but not constexpr)
    overload of __glibcxx_assert_fail to cause compilation to fail. That
    inline function doesn't cause an undefined reference to a symbol in the
    library (and will be optimized away anyway).

    We can also add always_inline to the __is_constant_evaluated function,
    although this doesn't actually matter for -O0 and it's always inlined
    with any optimization enabled.

    libstdc++-v3/ChangeLog:

            PR libstdc++/112882
            * include/bits/c++config (__is_constant_evaluated): Add
            always_inline attribute.
            (_GLIBCXX_DO_ASSERT): Remove macro.
            (__glibcxx_assert): Define separately for assertions-enabled and
            constexpr-only cases.

  parent reply	other threads:[~2023-12-07 20:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 15:20 [Bug libstdc++/112882] New: " tnfchris at gcc dot gnu.org
2023-12-06 16:47 ` [Bug libstdc++/112882] " redi at gcc dot gnu.org
2023-12-06 16:55 ` redi at gcc dot gnu.org
2023-12-06 17:07 ` redi at gcc dot gnu.org
2023-12-06 17:09 ` redi at gcc dot gnu.org
2023-12-06 17:20 ` redi at gcc dot gnu.org
2023-12-07  8:23 ` tnfchris at gcc dot gnu.org
2023-12-07  9:49 ` redi at gcc dot gnu.org
2023-12-07 20:55 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-07 21:03 ` 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-112882-4-g6oUPybVCv@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).