On 22/11/20 22:13 +0100, Stephan Bergmann wrote:
On 20/11/2020 23:44, Thomas Rodgers wrote:
Tested x86_64-pc-linux-gnu, committed.

Clang complains:

$ cat test.cc
#include <semaphore>

$ clang++ --gcc-toolchain=~/gcc/trunk/inst -std=c++20 -fsyntax-only test.cc
In file included from test.cc:1:
In file included from 
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/semaphore:36:
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/bits/semaphore_base.h:145:22:
 error: no viable conversion from 'std::chrono::system_clock::time_point' (aka 
'time_point<std::chrono::system_clock, duration<long, ratio<1, 1000000000>>>') 
to 'const std::__platform_semaphore::__clock_t' (aka 'const std::chrono::system_clock')
           const __clock_t __s_entry = __clock_t::now();
                           ^           ~~~~~~~~~~~~~~~~
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/chrono:1101:12: 
note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 
'std::chrono::system_clock::time_point' (aka 'time_point<std::chrono::system_clock, 
duration<long, ratio<1, 1000000000>>>') to 'const std::chrono::system_clock &' for 
1st argument
   struct system_clock
          ^
~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/chrono:1101:12: note: 
candidate constructor (the implicit move constructor) not viable: no known conversion from 
'std::chrono::system_clock::time_point' (aka 'time_point<std::chrono::system_clock, duration<long, 
ratio<1, 1000000000>>>') to 'std::chrono::system_clock &&' for 1st argument
1 error generated.

which

diff --git a/libstdc++-v3/include/bits/semaphore_base.h 
b/libstdc++-v3/include/bits/semaphore_base.h
index 78a0b6ba26e..f25c9fdb325 100644
--- a/libstdc++-v3/include/bits/semaphore_base.h
+++ b/libstdc++-v3/include/bits/semaphore_base.h
@@ -142,7 +142,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       else
         {
           const typename _Clock::time_point __c_entry = _Clock::now();
-           const __clock_t __s_entry = __clock_t::now();
+           const __clock_t::time_point __s_entry = __clock_t::now();
           const auto __delta = __atime - __c_entry;
           const auto __s_atime = __s_entry + __delta;
           if (_M_try_acquire_until_impl(__s_atime))
~

would fix.

I just used 'auto'` instead.

Committed, thanks.

The fact this didn't error with GCC suggests we're missing some tests.


commit 1ccee0fbfa8e528b3671dfbf4dad5b6f67755e4c
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Nov 23 18:16:44 2020

    libstdc++: Fix variable declared with wrong type
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/semaphore_base.h
            (__platform_semaphore::_M_try_acquire_until): Fix type of
            variable.

diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h
index 0692f95f24f2..56333bbbfef7 100644
--- a/libstdc++-v3/include/bits/semaphore_base.h
+++ b/libstdc++-v3/include/bits/semaphore_base.h
@@ -141,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	else
 	  {
 	    const typename _Clock::time_point __c_entry = _Clock::now();
-	    const __clock_t __s_entry = __clock_t::now();
+	    const auto __s_entry = __clock_t::now();
 	    const auto __delta = __atime - __c_entry;
 	    const auto __s_atime = __s_entry + __delta;
 	    if (_M_try_acquire_until_impl(__s_atime))

Reply via email to