[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

euloanty at live dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 24 09:57:00 GMT 2019


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

--- Comment #6 from fdlbxtqi <euloanty at live dot com> ---

> What operation are you doing on vector? None of your testcases seem to use
> it.


void copy_char_vector_with_iter(std::vector<char8_t>::iterator
out,std::vector<char> const& bits)
{
        std::copy_n(bits.begin(),bits.size(),out);
}

https://godbolt.org/z/_yA_Ls
See the assembly

> > clearly incorrect
> 
> Please distinguish between what is wrong (generated code crashes, or returns
> 3 instead of 2), and what is suboptimal.

Suppose #ifdef __cpp_lib_is_constant_evaluated is not defined (for C++17)

It becomes:
        return __builtin_memmove(__dst, __src, sizeof(_Tp) * __num);
      return __dst;

?????


More information about the Gcc-bugs mailing list