* [committed] libstdc++: Avoid -Wzero-as-null-pointer-constant warning [PR103848]
@ 2022-01-05 13:48 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-01-05 13:48 UTC (permalink / raw)
To: libstdc++, gcc-patches
Tested powerpc64le-linux, pushed to trunk.
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 | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index e4c53d56068..7fa9b0b3c09 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -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);
}
--
2.31.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-05 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 13:48 [committed] libstdc++: Avoid -Wzero-as-null-pointer-constant warning [PR103848] Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).