https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86471

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Matt Bentley from comment #6)
> Suggested patch for libstdc++, std_algobase.h, line 688:
>   template<typename _ForwardIterator, typename _Tp>
>     inline typename
>     __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type
>     __fill_a(_ForwardIterator __first, _ForwardIterator __last,
>            const _Tp& __value)
>     {
>       if (__value != reinterpret_cast<_Tp>(0))
>       {
>             const _Tp __tmp = __value;
>             for (; __first != __last; ++__first)
>               *__first = __tmp;
>               }
>               else
>               {
>             if (const size_t __len = __last - __first)
>               __builtin_memset(reinterpret_cast<void *>(__first), 0, __len *
> sizeof(_Tp));
>               }
>     }
> 
> Comments?
This is incorrect for floating point types and non scalars.  And it introduces
an extra check at runtime if value is not known to compile time.

Reply via email to