@@ -24,29 +24,29 @@ thread::native_handle_type thread::start_thread_impl(
2424 thread::start_routine_type start,
2525 void * arg)
2626{
27- // Set the requested stack size, if given.
28- unsigned stack_attr = 0 ;
29- if (stack_size > 0 )
27+ // Set the requested stack size, if given.
28+ unsigned stack_attr = 0 ;
29+ if (stack_size > 0 )
30+ {
31+ if (sizeof (unsigned ) <= sizeof (int32_t ) &&
32+ stack_size > static_cast <int32_t >(std::numeric_limits<unsigned >::max () / 2 ))
3033 {
31- if (sizeof (unsigned ) <= sizeof (int32_t ) &&
32- stack_size > static_cast <int32_t >(std::numeric_limits<unsigned >::max () / 2 ))
33- {
34- throw std::invalid_argument (" Cannot cast stack_size into unsigned" );
35- }
36-
37- stack_attr = static_cast <unsigned >(stack_size);
34+ throw std::invalid_argument (" Cannot cast stack_size into unsigned" );
3835 }
3936
40- // Construct and execute the thread.
41- HANDLE hnd = (HANDLE ) ::_beginthreadex (NULL , stack_attr, start, arg, 0 , NULL );
42- if (!hnd)
43- {
44- throw std::system_error (std::make_error_code (std::errc::resource_unavailable_try_again));
45- }
37+ stack_attr = static_cast <unsigned >(stack_size);
38+ }
4639
47- return hnd;
40+ // Construct and execute the thread.
41+ HANDLE hnd = (HANDLE ) ::_beginthreadex (NULL , stack_attr, start, arg, 0 , NULL );
42+ if (!hnd)
43+ {
44+ throw std::system_error (std::make_error_code (std::errc::resource_unavailable_try_again));
4845 }
4946
47+ return hnd;
48+ }
49+
5050thread::id thread::get_thread_id_impl (
5151 thread::native_handle_type hnd)
5252{
0 commit comments