[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
Sun Oct 20 07:45:55 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:
Well, cppreference isn't exactly normative. Anyways, where is the actual disconnect? Is it whether you're allowed to
- inspect the bytes of a non-trivially copyable object
- implicitly start the lifetime of a trivial type with bytes from a different object
- do any of the above via `memcpy`
- do the above together in a single `memcpy`
- something else?
https://github.com/llvm/llvm-project/pull/111434
More information about the cfe-commits
mailing list