https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115740
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> --- I wonder if this would work: --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -610,7 +610,9 @@ namespace std # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif +#if !(__has_attribute(__device__) && defined(__device__)) #undef _GLIBCXX_VERBOSE_ASSERT +#endif // Assert. #ifdef _GLIBCXX_VERBOSE_ASSERT @@ -645,17 +647,10 @@ namespace std // _GLIBCXX_ASSERTIONS is not defined, so assertions checks are only enabled // during constant evaluation. This ensures we diagnose undefined behaviour // in constant expressions. -namespace std -{ - __attribute__((__always_inline__,__visibility__("default"))) - inline void - __glibcxx_assert_fail() - { } -} # define __glibcxx_assert(cond) \ do { \ if (std::__is_constant_evaluated() && !bool(cond)) \ - std::__glibcxx_assert_fail(); \ + _GLIBCXX_ASSERT_FAIL(cond); \ } while (false) #else // _GLIBCXX_ASSERTIONS is not defined and __is_constant_evaluated() doesn't This would disable the verbose assert when __device__ is defined, and so always use __builtin_abort() for assertions (at runtime and at compile-time in constexpr). Replace __device__ with some other suitable macro(s) like (__HIPCC_ || __CUDACC__) or something.