public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi 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: Wed, 06 Dec 2023 16:47:00 +0000	[thread overview]
Message-ID: <bug-112882-4-w1uZAid0UJ@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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-12-06
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Tamar Christina from comment #0)
> I know this is not a supported scenario, but I'm wondering if it's still
> easy to support.
> 
> We have some libraries that use C++ mostly as an abstraction layer and try
> to ensure that it needs no runtime support from libstdc++.
> 
> A recent commit: g:5e8a30d8b8f4d7ea0a8340b46c1e0c865dbde781 changed how
> `__glibcxx_assert` is defined and now always calls
> `std::__glibcxx_assert_fail`.
> 
> This means that now you always need libstdc++ even in contex where things
> would have been folded away before.  Similarly we're getting the same thing
> through usage of `std::unique_ptr`.

Ugh, that's undesirable. It should only depend on that symbol when
_GLIBCXX_ASSERTIONS is defined, but the change means we also use that symbol
for constexpr checks.

I'm surprised it doesn't get folded away though, since the code looks like:

  if (std::__is_constant_evaluated())
    if (__builtin_expect(COND, false))
      __glibcxx_assert_fail(...);

Since __is_constant_evaluated is always false at runtime, that function can
never be called. Either it's needed during compile-time and makes the program
ill-formed, or it's not needed at all.

Ah, __is_constant_evaluated() is not marked always_inline, so at -O0 it just
looks like a normal function call.

> It seems that undefining `_GLIBCXX_VERBOSE_ASSERT` gets it to go to
> `__builtin_abort()` which makes it work again.
> 
> If this change was intentional, would it be possible to make
> `_GLIBCXX_VERBOSE_ASSERT` user configurable?

You can use --disable-libstdcxx-verbose for that, or do you need to control it
during preprocessing?

  reply	other threads:[~2023-12-06 16:47 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 ` redi at gcc dot gnu.org [this message]
2023-12-06 16:55 ` [Bug libstdc++/112882] " 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
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-w1uZAid0UJ@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).