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

--- Comment #39 from fdlbxtqi <euloanty at live dot com> ---
(In reply to Jonathan Wakely from comment #38)
> We could also use memcmp for std::equal when it's using std::equal_to<> or
> std::equal_to<_ValueType1> or std::equal_to<_ValueType2>, and for
> std::lexicographical_compare when it's using std::less<> or
> std::less<_ValueType1> or std::less<_ValueType2> (as long as the existing
> conditions are also met).
> 
> Currently we only use memcmp when those algos are used without a comparison
> function.

Hi Jonathan. Another bug I found before and you haven't fixed:
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_algobase.h#L1706

const auto __c = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0;


You cannot call &*__first, &*__first2 for contiguous_iterator since a lot of
implementations of contiguous iterators will check bounds at debugging mode
(for example MSVC's STL vector implementation). Yours will break code. __second
is not allowed to dereference, that is UB.

Instead, you should call to_address(__first),to_address(__second)

Reply via email to