[clang] [compiler-rt] [libcxx] [llvm] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 22 05:36:43 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));
----------------
philnik777 wrote:
I think the part that gives inspecting an object well-defined behaviour is http://eel.is/c++draft/basic.types#general-4. I'm not 100% sure, though. There might be something more explicit (I was hoping someone here knows). https://eel.is/c++draft/cstring.syn#3 also states that "[The `memcpy` and `memmove`] functions implicitly create objects ([[intro.object]](https://eel.is/c++draft/intro.object)) in the destination region of storage immediately prior to copying the sequence of characters to the destination", which sounds to me a lot like it's allowed to copy the bytes _from_ anywhere.
https://github.com/llvm/llvm-project/pull/111434
More information about the cfe-commits
mailing list