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.
---

Tested x86_64-linux and aarch64-linux.

 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
-- 
2.52.0

Reply via email to