[Bug libstdc++/93059] char and char8_t does not talk with each other with memcpy. std::copy std::copy_n, std::fill, std::fill_n, std::uninitialized_copy std::uninitialized_copy_n, std::fill, std::uninitialized_fill_n fails to convert to memxxx functions

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 3 09:46:00 GMT 2020


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

--- Comment #42 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to fdlbxtqi from comment #39)
> Hi Jonathan. Another bug I found before and you haven't fixed:

Have you reported it?

> 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.

How? The iterators are only dereferenced when __len is non-zero.

And how would MSVC's vector be used with libstdc++ algorithms?

Do you have a testcase demonstrating an actual problem?

> __second is not allowed to dereference, that is UB.

What is __second?


More information about the Gcc-bugs mailing list