From f67c6653acecc9f645e7b95e74fa4abde105410e Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Mon, 11 Aug 2025 15:15:26 -0700 Subject: [PATCH] Fix compilation error using CLANG (#13864) Summary: fix the following error showing up in continuous tests: ``` Makefile:186: Warning: Compiling in debug mode. Don't use the resulting binary in production port/mmap.cc:46:15: error: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'rocksdb::MemMapping' [-Werror,-Wnontrivial-memcall] 46 | std::memcpy(this, &other, sizeof(*this)); | ^ port/mmap.cc:46:15: note: explicitly cast the pointer to silence this warning 46 | std::memcpy(this, &other, sizeof(*this)); | ^ | (void*) 1 error generated. make: *** [Makefile:2580: port/mmap.o] Error 1 make: *** Waiting for unfinished jobs.... ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/13864 Test Plan: `make USE_CLANG=1 j=150 check` with https://github.com/facebook/rocksdb/blob/13f054febb26100184eeefaac11877d735d45ac2/build_tools/build_detect_platform#L61-L70 commented out. Reviewed By: mszeszko-meta Differential Revision: D80033441 Pulled By: cbi42 fbshipit-source-id: b2330eea71fe28243236b75128ec6f3f1e971873 Signed-off-by: Yishuai Li --- port/mmap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/mmap.cc b/port/mmap.cc index 36e8f32617fb..36977f17b9f4 100644 --- a/port/mmap.cc +++ b/port/mmap.cc @@ -43,7 +43,7 @@ MemMapping& MemMapping::operator=(MemMapping&& other) noexcept { return *this; } this->~MemMapping(); - std::memcpy(this, &other, sizeof(*this)); + std::memcpy(static_cast(this), &other, sizeof(*this)); new (&other) MemMapping(); return *this; }