libstdc++: Avoid -Wzero-as-null-pointer-constant warning [PR103848]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 4 Jan 2022 21:57:16 +0000 (21:57 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 5 Jan 2022 13:47:02 +0000 (13:47 +0000)
libstdc++-v3/ChangeLog:

PR libstdc++/103848
* include/bits/stl_deque.h (operator-): Do not use 0 as null
pointer constant.

libstdc++-v3/include/bits/stl_deque.h

index e4c53d5..7fa9b0b 100644 (file)
@@ -370,7 +370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
       {
        return difference_type(_S_buffer_size())
-         * (__x._M_node - __y._M_node - int(__x._M_node != 0))
+         * (__x._M_node - __y._M_node - bool(__x._M_node))
          + (__x._M_cur - __x._M_first)
          + (__y._M_last - __y._M_cur);
       }
@@ -383,10 +383,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        _GLIBCXX_NODISCARD
        friend difference_type
        operator-(const _Self& __x,
-                 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
+                 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
+       _GLIBCXX_NOEXCEPT
        {
          return difference_type(_S_buffer_size())
-           * (__x._M_node - __y._M_node - int(__x._M_node != 0))
+           * (__x._M_node - __y._M_node - bool(__x._M_node))
            + (__x._M_cur - __x._M_first)
            + (__y._M_last - __y._M_cur);
        }