]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Disable false positive middle end warnings in std::shared_ptr [PR122197]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 23 Jan 2026 14:25:03 +0000 (14:25 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 28 Jan 2026 10:28:09 +0000 (10:28 +0000)
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 <tkaminsk@redhat.com>
libstdc++-v3/include/bits/shared_ptr_base.h

index 88e0f4d58c6ceac24bf39a92295a556abca1c3ee..b92e3a4c90e41c349cb6c74f05081866bda61390 100644 (file)
@@ -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