summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/bits/stl_algobase.h
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/bits/stl_algobase.h')
-rw-r--r--libstdc++-v3/include/bits/stl_algobase.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 2cef9237d76..c638c547887 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;
}
};
OpenPOWER on IntegriCloud