https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115824

--- Comment #11 from Iru Cai <mytbk920423 at gmail dot com> ---
(In reply to Sam James from comment #7)
> (In reply to Randy MacLeod from comment #5)
> 
> As far as I know, the commit itself is fine, and it's the pesky middle-end
> warnings again getting confused.
> 
> Jonathan might be willing to try rework it to avoid the warnings but it's a
> lot of busywork and not particularly satisfying.
> 
> If someone can suggest some trivial change which shuts it up, that might
> work.

We can just use these "pragma GCC diagnostic" things to silence this warnings.
Also I found that it also has strange warnings with -Wstringop-overread, so I
add this to the ignored.

diff --git a/libstdc++-v3/include/bits/stl_algobase.h
b/libstdc++-v3/include/bits/stl_algobase.h
index 6e648e48ad0..312d5242d70 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -430,9 +430,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        __copy_m(_Tp* __first, _Tp* __last, _Up* __result)
        {
          const ptrdiff_t _Num = __last - __first;
-         if (__builtin_expect(_Num > 1, true))
+         if (__builtin_expect(_Num > 1, true)) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wstringop-overread"
            __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
-         else if (_Num == 1)
+#pragma GCC diagnostic pop
+         } else if (_Num == 1)
            std::__copy_move<_IsMove, false, random_access_iterator_tag>::
              __assign_one(__result, __first);
          return __result + _Num;

Reply via email to