Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Sep 2025 22:35:26 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 34a006eaa39c - main - libc++: silence -Wnontrivial-memaccess warning with newer clang
Message-ID:  <202509152235.58FMZQjR031350@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=34a006eaa39ceb6b0a96fa386c9b9b8a44681979

commit 34a006eaa39ceb6b0a96fa386c9b9b8a44681979
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2025-09-15 22:14:18 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2025-09-15 22:14:18 +0000

    libc++: silence -Wnontrivial-memaccess warning with newer clang
    
    Apply part of LLVM commit 71315698c91d0cda054b903da0594ca6f072c350 to
    silence the -Wnontrivial-memaccess warning that is triggered any time
    this function is instantiated by user code. This fixes another
    buildworld failure with Clang HEAD.
    
    Original commit message:
    [clang] Warn about memset/memcpy to NonTriviallyCopyable types (#111434)
    This implements a warning that's similar to what GCC does in that
    context: both memcpy and memset require their first and second operand
    to be trivially copyable, let's warn if that's not the case.
    
    Reviewed by:    emaste, dim
    MFC after:      1 week
    Differential Revision: https://reviews.freebsd.org/D52534
---
 .../llvm-project/libcxx/include/__memory/uninitialized_algorithms.h    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
index 7475ef5cf85d..79cab80dcf73 100644
--- a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
@@ -642,7 +642,8 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _
     __guard.__complete();
     std::__allocator_destroy(__alloc, __first, __last);
   } else {
-    __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first));
+    // Casting to void* to suppress clang complaining that this is technically UB.
+    __builtin_memcpy(static_cast<void*>(const_cast<__remove_const_t<_Tp>*>(__result)), __first, sizeof(_Tp) * (__last - __first));
   }
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509152235.58FMZQjR031350>