https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108846
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Giuseppe D'Angelo from comment #5) > https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/ > stl_algobase.h#L417-L437 > > Is the extent of the fix just to add another branch to the if (_Num) check > here? Yes, I think that's the simplest place to fix it. And we can even get rid of the static assertion, because the Num==1 branch will require assignability now. --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -737,16 +737,11 @@ _GLIBCXX_END_NAMESPACE_CONTAINER static _Tp* __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) { -#if __cplusplus >= 201103L - using __assignable = __conditional_t<_IsMove, - is_move_assignable<_Tp>, - is_copy_assignable<_Tp>>; - // trivial types can have deleted assignment - static_assert( __assignable::value, "type must be assignable" ); -#endif const ptrdiff_t _Num = __last - __first; - if (_Num) + if (__builtin_expect(_Num > 1, true)) __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); + else if (_Num == 1) + *__result = *__first; return __result - _Num; } };