From: Jonathan Wakely Date: Fri, 6 Jun 2025 13:16:15 +0000 (+0100) Subject: libstdc++: Use std::conditional_t instead of lambda to select semaphore implementation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7407891a3d7c177212c6027c1dee08bed096666b;p=thirdparty%2Fgcc.git libstdc++: Use std::conditional_t instead of lambda to select semaphore implementation The lambda expression causes testsuite failures such as: FAIL g++.dg/modules/xtreme-header-2_b.C -std=c++26 (test for excess errors) libstdc++-v3/ChangeLog: * include/bits/semaphore_base.h (_Select_semaphore_impl): Rename to _Semaphore_impl and use std::conditional_t instead of an immediately invoked lambda expression. * include/std/semaphore (counting_semaphore): Adjust to use new name. --- diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h index ebbc9a80b91..82871ce3518 100644 --- a/libstdc++-v3/include/bits/semaphore_base.h +++ b/libstdc++-v3/include/bits/semaphore_base.h @@ -289,22 +289,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION alignas(__detail::__platform_wait_alignment) __count_type _M_counter; }; - template - using _Select_semaphore_impl = typename decltype([] - { - using namespace __detail; - if constexpr (__platform_wait_uses_type<__platform_wait_t>) - { - if constexpr (_Max <= 1) - return type_identity<__platform_semaphore_impl>{}; - else if constexpr (_Max <= __platform_semaphore_impl::_S_max) - return type_identity<__platform_semaphore_impl>{}; - else - return type_identity<__semaphore_impl>{}; - } - else - return type_identity<__semaphore_impl>{}; - }())::type; + template + using _Semaphore_impl + = __conditional_t<__platform_wait_uses_type<_Tp> + && _Max <= __gnu_cxx::__int_traits<_Tp>::__max, + __platform_semaphore_impl<(_Max <= 1)>, + __semaphore_impl>; _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/std/semaphore b/libstdc++-v3/include/std/semaphore index 8f49188563e..18d04075776 100644 --- a/libstdc++-v3/include/std/semaphore +++ b/libstdc++-v3/include/std/semaphore @@ -45,12 +45,12 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - template::_S_max> + template::_S_max> class counting_semaphore { static_assert(__least_max_value >= 0); - _Select_semaphore_impl<__least_max_value> _M_sem; + _Semaphore_impl<__least_max_value> _M_sem; public: constexpr explicit