https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105810
--- Comment #4 from cqwrteur <unlvsur at live dot com> ---
(In reply to cqwrteur from comment #3)
> (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]] \
> > { \
> > \
> > 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>();
> > \
> > }\
> > }
> >
> >
> > This instantiates a new instance of __my_glibcxx_constexpr_assert<T> with a
> > new T for every assertion, but the actual call to __glibcxx_assert_fail is
> > in a cold function instead of inlined into the assertion.
>
> yep.
btw since the function is inline linkaged, the entire program would only
contain one copy of __my_glibcxx_constexpr_assert<T>. For example for
std::span::operator[] the entire program shares the bounds checking part.