From e9eafcca9f72ee519eece60765719f6ff5feda03 Mon Sep 17 00:00:00 2001 From: Navneet Kumar <4686373+navneet83@users.noreply.github.com> Date: Thu, 3 Sep 2026 22:56:23 -0700 Subject: [PATCH] Suppress `lifetime-safety-return-stack-addr-moved` from clang 23, not 24 The suppression was gated on clang 24 on the assumption that nothing below it emits the diagnostic. Clang 23 emits it, so a build with clang 23 fails: the warning is on by default, `WERROR` is on by default, and `src/Parsers/Prometheus/PrometheusQueryTree.cpp:165` trips it ten times, once per template instantiation. error: stack memory associated with local variable 'new_node' may be returned later. This could be a false positive as the storage may have been moved. [-Werror,-Wlifetime-safety-return-stack-addr-moved] The three related `lifetime-safety` diagnostics are already gated on 23 and are suppressed correctly; only this one is not, so the compile command carries `-Wno-lifetime-safety-intra-tu-suggestions`, `-Wno-lifetime-safety-cross-tu-suggestions` and `-Wno-lifetime-safety-invalidation` but not this one. Nothing about the code is wrong - the `unique_ptr` payload is on the heap and outlives the local, which the comment already says. Lower the gate to match the compiler that actually emits it, and drop the stale note about clang 24 being Emscripten-only. --- cmake/warnings.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/warnings.cmake b/cmake/warnings.cmake index deb9925b8ec9d..3a6c569106dd6 100644 --- a/cmake/warnings.cmake +++ b/cmake/warnings.cmake @@ -60,13 +60,12 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 23) # references to the container's elements would be invalidated. no_warning(lifetime-safety-invalidation) endif () -if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 24) +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 23) # Too many false positives: it flags the pervasive idiom of taking a raw pointer out # of a `unique_ptr`, moving the owner into a container and returning the pointer - # the storage is on the heap and outlives the local, and the diagnostic text itself # concedes it "could be a false positive as the storage may have been moved". - # Nothing links clang 24 today except the Emscripten build (its clang is ahead of the - # default toolchain); re-evaluate when the default toolchain catches up. + # Emitted from clang 23 on, alongside the three related diagnostics suppressed above. no_warning(lifetime-safety-return-stack-addr-moved) endif () if (ARCH_E2K)