[clang] [compiler-rt] [libcxx] [llvm] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 19 12:22:08 PDT 2024
================
@@ -102,7 +102,7 @@ struct __aliasing_iterator_wrapper {
_LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT {
_Alias __val;
- __builtin_memcpy(&__val, std::__to_address(__base_), sizeof(value_type));
+ __builtin_memcpy(&__val, static_cast<const void*>(std::__to_address(__base_)), sizeof(value_type));
----------------
carlosgalvezp wrote:
[cppreference](https://en.cppreference.com/w/cpp/string/byte/memcpy) used to say that it was UB, but now they have changed it to "may be UB":
Honestly, I cannot find any reference in the C++ Standard about this, maybe it's indirectly from [basic.life] of something. The C standard only says:
> The memcpy function copies n characters from the object pointed to by s2 into the object pointed to
by s1. If copying takes place between objects that overlap, the behavior is undefined.
https://github.com/llvm/llvm-project/pull/111434
More information about the cfe-commits
mailing list