gcc/libstdc++-v3/testsuite/30_threads
Jonathan Wakely 89552346e3
libstdc++: Fix std::counting_semaphore<> default max value
My recent (uncommitted) changes to support a 64-bit __platform_wait_t
for FreeBSD and Darwin revealed a problem in std::counting_semaphore.
When the default template argument is used and __platform_wait_t is a
64-bit type, the numeric_limits<__platform_wait_t>::max() value doesn't
fit in ptrdiff_t and so we get ptrdiff_t(-1), which fails a
static_assert in the class body.

The solution is to cap the value to PTRDIFF_MAX instead of allowing it
to go negative.

libstdc++-v3/ChangeLog:

	* include/bits/semaphore_base.h (__platform_semaphore::_S_max):
	Limit to PTRDIFF_MAX to avoid negative values.
	* testsuite/30_threads/semaphore/least_max_value.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-11-27 09:43:24 +00:00
..
async Update copyright years. 2025-01-02 11:59:57 +01:00
barrier libstdc++: Adjust effective-target requirements for <barrier> and <semaphore> 2025-06-06 17:29:28 +01:00
call_once Update copyright years. 2025-01-02 11:59:57 +01:00
condition_variable libstdc++: Add missing -pthread for new tests [PR122401] 2025-10-27 18:24:20 +00:00
condition_variable_any Update copyright years. 2025-01-02 11:59:57 +01:00
future libstdc++: Add missing -pthread for new tests [PR122401] 2025-10-27 18:24:20 +00:00
headers Update copyright years. 2025-01-02 11:59:57 +01:00
jthread Update copyright years. 2025-01-02 11:59:57 +01:00
latch libstdc++: Use safe integer comparisons in std::latch [PR98749] 2025-01-30 11:22:28 +00:00
lock Update copyright years. 2025-01-02 11:59:57 +01:00
lock_guard Update copyright years. 2025-01-02 11:59:57 +01:00
mutex Update copyright years. 2025-01-02 11:59:57 +01:00
packaged_task libstdc++: Explicitly pass -Wsystem-headers in tests that need it 2025-09-16 20:59:10 -04:00
promise Update copyright years. 2025-01-02 11:59:57 +01:00
recursive_mutex Update copyright years. 2025-01-02 11:59:57 +01:00
recursive_timed_mutex libstdc++: Add missing -pthread for new tests [PR122401] 2025-10-27 18:24:20 +00:00
scoped_lock libstdc++: Restore std::scoped_lock for non-gthreads targets [PR120198] 2025-05-12 12:26:53 +01:00
semaphore libstdc++: Fix std::counting_semaphore<> default max value 2025-11-27 09:43:24 +00:00
shared_future Update copyright years. 2025-01-02 11:59:57 +01:00
shared_lock libstdc++: Make std::unique_lock self-move-assignable 2025-03-06 16:46:19 +00:00
shared_mutex Update copyright years. 2025-01-02 11:59:57 +01:00
shared_timed_mutex libstdc++: shared_mutex: Respond consistently to errors and deadlock 2025-11-18 17:13:44 +00:00
stop_token c++: Unwrap type traits defined in terms of builtins within diagnostics [PR117294] 2025-07-25 08:18:45 +10:00
this_thread libstdc++: Add negative this_thread::sleep tests [PR116586] 2025-10-14 17:26:44 +01:00
thread libstdc++: Do not include internal headers in tests 2025-10-29 17:22:39 +00:00
timed_mutex libstdc++: Add missing -pthread for new tests [PR122401] 2025-10-27 18:24:20 +00:00
try_lock Update copyright years. 2025-01-02 11:59:57 +01:00
unique_lock libstdc++: Make std::unique_lock self-move-assignable 2025-03-06 16:46:19 +00:00