https://gcc.gnu.org/g:74e0bb3faacfccfdf5633ab7ad3a15549d4a954d
commit r16-7106-g74e0bb3faacfccfdf5633ab7ad3a15549d4a954d Author: Jonathan Wakely <[email protected]> Date: Fri Jan 23 14:25:03 2026 +0000 libstdc++: Disable false positive middle end warnings in std::shared_ptr [PR122197] 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 <[email protected]> Diff: --- 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 88e0f4d58c6c..b92e3a4c90e4 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<typename> 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
