[clang] [compiler-rt] [libcxx] [llvm] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)

Nikolas Klauser via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 13:40:10 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 so. If this is indeed UB we can still add the warnings later. It's always harder to get users to re-enable a warning than to introduce it in the first place. But let's see what @AaronBallman's thoughts on this are.

https://github.com/llvm/llvm-project/pull/111434


More information about the llvm-commits mailing list