diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-10-04 18:11:06 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-10-09 13:41:06 +0100 |
commit | f5021ce9aa6be524beca99e0bbd0180b4e53029b (patch) | |
tree | 21f5fb5785400f264a19f326d51bbf9210f4af5a | |
parent | 361d230fd7800a7e749aba8ed020f54f5c26d504 (diff) | |
download | gcc-f5021ce9aa6be524beca99e0bbd0180b4e53029b.zip gcc-f5021ce9aa6be524beca99e0bbd0180b4e53029b.tar.gz gcc-f5021ce9aa6be524beca99e0bbd0180b4e53029b.tar.bz2 |
libstdc++: Fix -Wsign-compare in std::latch::count_down
Also add assertions for the precondition on the parameter's value.
libstdc++-v3/ChangeLog:
* include/std/latch (latch::count_down): Add assertions for
preconditions. Cast parameter to avoid -Wsign-compare on some
targets.
-rw-r--r-- | libstdc++-v3/include/std/latch | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch index 146e186..1d254aa 100644 --- a/libstdc++-v3/include/std/latch +++ b/libstdc++-v3/include/std/latch @@ -63,9 +63,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_ALWAYS_INLINE void count_down(ptrdiff_t __update = 1) { + __glibcxx_assert(__update >= 0); auto const __old = __atomic_impl::fetch_sub(&_M_a, __update, memory_order::release); - if (__old == __update) + __glibcxx_assert(__update >= 0); + if (__old == static_cast<__detail::__platform_wait_t>(__update)) __atomic_impl::notify_all(&_M_a); } @@ -88,6 +90,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } private: + // This alignas is not redundant, it increases the alignment for + // long long on x86. alignas(__alignof__(__detail::__platform_wait_t)) __detail::__platform_wait_t _M_a; }; _GLIBCXX_END_NAMESPACE_VERSION |