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 17:07:35 +0000 [thread overview] Message-ID: <bug-112882-4-OUEG2hq3ME@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 #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- That change was broken anyway: when _GLIBCXX_ASSERTIONS was not defined, the condition in the assertion is if constexpr (is_constant_evaluated()) which is always true, even when not actually doing constant eval. I'll test this: --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -538,6 +538,7 @@ namespace std // This can be used without checking if the compiler supports the feature. // The macro _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED can be used to check if // the compiler support is present to make this function work as expected. + __attribute__((__always_inline__)) _GLIBCXX_CONSTEXPR inline bool __is_constant_evaluated() _GLIBCXX_NOEXCEPT { @@ -589,19 +590,28 @@ namespace std #endif #if defined(_GLIBCXX_ASSERTIONS) -# define _GLIBCXX_DO_ASSERT true -#elif _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED -# define _GLIBCXX_DO_ASSERT std::__is_constant_evaluated() -#else -# define _GLIBCXX_DO_ASSERT false -#endif - # define __glibcxx_assert(cond) \ do { \ - if _GLIBCXX17_CONSTEXPR (_GLIBCXX_DO_ASSERT) \ - if (__builtin_expect(!bool(cond), false)) \ - _GLIBCXX_ASSERT_FAIL(cond); \ + if (__builtin_expect(!bool(cond), false)) \ + _GLIBCXX_ASSERT_FAIL(cond); \ } while (false) +#elif _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED +namespace std +{ + __attribute__((__always_inline__,visibility("default"))) + inline void + __glibcxx_compile_time_assert_fail() + { } +} +# define __glibcxx_assert(cond) \ + do { \ + if (std::__is_constant_evaluated()) \ + if (__builtin_expect(!bool(cond), false)) \ + __glibcxx_compile_time_assert_fail(); \ + } while (false) +#else +# define __glibcxx_assert(cond) +#endif // Macro indicating that TSAN is in use. #if __SANITIZE_THREAD__
next prev parent reply other threads:[~2023-12-06 17:07 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 [this message] 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-OUEG2hq3ME@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: linkBe 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).