Skip to content

Commit 3277f05

Browse files
committed
cmake: suppress -Wmaybe-uninitialized warning in memstore PageSet
Suppress GCC-15 false positive warning about uninitialized memory in Page::operator delete() using placement new pattern. GCC-15 incorrectly warns about potentially uninitialized data when using placement new with manual memory management: ``` [409/506] Building CXX object src/os/CMakeFiles/os.dir/memstore/MemStore.cc.o In file included from /home/kefu/dev/ceph/src/os/memstore/MemStore.h:29, from /home/kefu/dev/ceph/src/os/memstore/MemStore.cc:28: In static member function ‘static void Page::operator delete(void*)’, inlined from ‘void Page::put()’ at /home/kefu/dev/ceph/src/os/memstore/PageSet.h:36:41: /home/kefu/dev/ceph/src/os/memstore/PageSet.h:83:42: warning: ‘*this.Page::data’ may be used uninitialized [-Wmaybe-uninitialized] 83 | delete[] reinterpret_cast<Page*>(p)->data; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ ``` The warning is a false positive: Page instances are constructed using placement new over pre-allocated memory, requiring manual cleanup of the underlying data array. This is the intended behavior and memory is properly initialized. So, in this change we just silence this warning in CMake after checking its availability. Signed-off-by: Kefu Chai <[email protected]>
1 parent e663ede commit 3277f05

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/os/memstore/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1+
include(CheckCXXCompilerFlag)
2+
13
add_library(memstore
24
MemStore.cc)
5+
check_cxx_compiler_flag("-Wno-maybe-uninitialized"
6+
HAS_WARNING_MAYBE_UNINITIALIZED)
7+
if(HAS_WARNING_MAYBE_UNINITIALIZED)
8+
target_compile_options(os
9+
PRIVATE "-Wno-maybe-uninitialized")
10+
endif()

0 commit comments

Comments
 (0)