From 74e0bb3faacfccfdf5633ab7ad3a15549d4a954d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 23 Jan 2026 14:25:03 +0000 Subject: [PATCH] libstdc++: Disable false positive middle end warnings in std::shared_ptr [PR122197] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Speculative devirtualization in GCC 16 causes some false positive warnings for unreachable paths. Use diagnostic pragmas to suppress those warnings until the regression is fixed. libstdc++-v3/ChangeLog: PR tree-optimization/122197 * include/bits/shared_ptr_base.h (~_Sp_counted_deleter): Use diagnostic pragam to disable -Wfree-nonheap-object false positive. (~_Sp_counted_ptr_inplace): Likewise for -Warray-bounds false positive. Reviewed-by: Tomasz KamiƄski --- libstdc++-v3/include/bits/shared_ptr_base.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 88e0f4d58c6..b92e3a4c90e 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -579,7 +579,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept : _M_impl(__p, std::move(__d), __a) { } +#pragma GCC diagnostic push // PR tree-optimization/122197 +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + template class auto_ptr; ~_Sp_counted_deleter() noexcept { } +#pragma GCC diagnostic pop virtual void _M_dispose() noexcept @@ -667,7 +671,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::forward<_Args>(__args)...); // might throw } +#pragma GCC diagnostic push // PR tree-optimization/122197 +#pragma GCC diagnostic ignored "-Warray-bounds" ~_Sp_counted_ptr_inplace() noexcept { } +#pragma GCC diagnostic pop virtual void _M_dispose() noexcept