https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101608
--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
This may help:
--- a/ranges_algobase.h
+++ b/ranges_algobase.h
@@ -525,16 +525,22 @@ namespace ranges
if (__n <= 0)
return __first;
- // TODO: Generalize this optimization to contiguous iterators.
- if constexpr (is_pointer_v<_Out>
- // Note that __is_byte already implies !is_volatile.
- && __is_byte<remove_pointer_t<_Out>>::__value
- && integral<_Tp>)
+#ifdef __cpp_lib_is_constant_evaluated
+ if (!std::is_constant_evaluated())
+#endif
{
- __builtin_memset(__first, static_cast<unsigned char>(__value),
__n);
- return __first + __n;
+ // TODO: Generalize this optimization to contiguous iterators.
+ if constexpr (is_pointer_v<_Out>
+ // Note that __is_byte already implies !is_volatile.
+ && __is_byte<remove_pointer_t<_Out>>::__value
+ && integral<_Tp>)
+ {
+ __builtin_memset(__first, static_cast<unsigned char>(__value),
__n);
+ return __first + __n;
+ }
}
- else if constexpr (is_scalar_v<_Tp>)
+
+ if constexpr (is_scalar_v<_Tp>)
{
const auto __tmp = __value;
for (; __n > 0; --__n, (void)++__first)