From 7050b5fc6f40b601badd486e7624aa641132d91a Mon Sep 17 00:00:00 2001 From: paolo Date: Sun, 6 Sep 2009 15:41:38 +0000 Subject: [PATCH] 2009-09-06 Paolo Carlini PR libstdc++/41267 * include/bits/stl_algobase.h (__copy_move::__copy_m, __copy_move_backward::__copy_move_b): Don't call __builtin_memmove with a null third argument. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151459 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 7 +++++++ libstdc++-v3/include/bits/stl_algobase.h | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 44da8a3..acc7355 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2009-09-06 Paolo Carlini + + PR libstdc++/41267 + * include/bits/stl_algobase.h (__copy_move::__copy_m, + __copy_move_backward::__copy_move_b): Don't call __builtin_memmove + with a null third argument. + 2009-09-04 Benjamin Kosnik Revert. diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 2cef923..c638c54 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -375,9 +375,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) static _Tp* __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result) { - __builtin_memmove(__result, __first, - sizeof(_Tp) * (__last - __first)); - return __result + (__last - __first); + const ptrdiff_t _Num = __last - __first; + if (_Num) + __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); + return __result + _Num; } }; @@ -572,7 +573,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) { const ptrdiff_t _Num = __last - __first; - __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); + if (_Num) + __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); return __result - _Num; } }; -- 2.7.4