Tested x86_64-linux. Pushed to trunk. -- >8 --
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. --- libstdc++-v3/include/std/latch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/latch b/libstdc++-v3/include/std/latch index 146e1860979..1d254aa2581 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 -- 2.46.2