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__