+2015-05-29 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/66327
+ * include/bits/stl_algobase.h (__equal<true>::equal): Do not call
+ memcmp with null pointers.
+ (__lexicographical_compare<true>::__lc): Do not call memcmp for empty
+ ranges.
+
2015-05-28 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/65352
static bool
equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2)
{
+ if (__first1 == 0 || __first2 == 0)
+ return __first1 == __last1;
+
return !__builtin_memcmp(__first1, __first2, sizeof(_Tp)
* (__last1 - __first1));
}
{
const size_t __len1 = __last1 - __first1;
const size_t __len2 = __last2 - __first2;
- const int __result = __builtin_memcmp(__first1, __first2,
- std::min(__len1, __len2));
- return __result != 0 ? __result < 0 : __len1 < __len2;
+ if (__len1 && __len2)
+ {
+ if (int __result = __builtin_memcmp(__first1, __first2,
+ std::min(__len1, __len2)))
+ {
+ return __result < 0;
+ }
+ }
+ return __len1 < __len2;
}
};