https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105810
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #2) > Specifically, the suggested implementation is: > > template<typename __glibcxxassertiontype> > [[noreturn,__gnu__::__cold__,__gnu__::__noinline__]] > inline void __my_glibcxx_constexpr_assert() noexcept > { > constexpr __glibcxxassertiontype __assertinfo; > > __glibcxx_assert_fail(__assertinfo.__glibcxx_assertion_file,__assertinfo. > __glibcxx_assertion_line, > > __assertinfo.__glibcxx_pretty_function,__assertinfo. > __glibcxx_assertion_condition); > } > > #define my_glibcxx_assert(_Condition) \ > { \ > if (!bool(_Condition))[[unlikely]] \ N.B. we can't use [[unlikely]] in C++98 mode, it needs to be __builtin_expect. We can't even use [[unlikely]] in C++11, it would need to be [[__unlikely__]]. > { \ > \ > constexpr char const* __glibcxx_pretty_function_impl = > __PRETTY_FUNCTION__;\ > struct __glibcxxassertion{\ > char const* __glibcxx_assertion_file=__FILE__;\ > int __glibcxx_assertion_line=__LINE__;\ > char const* __glibcxx_pretty_function="";\ > char const* __glibcxx_assertion_condition=#_Condition;\ > };\ > __my_glibcxx_constexpr_assert<__glibcxxassertion>(); > \ We can't use a local class as a template argument in C++98, because the type has no linkage.