public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a
@ 2022-11-27 17:52 lukaszcz18 at wp dot pl
  2022-11-27 17:56 ` [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 pinskia at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-27 17:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

            Bug ID: 107886
           Summary: Problem witch std::latch, std::binary_semaphores in
                    C++2a
           Product: gcc
           Version: 11.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lukaszcz18 at wp dot pl
  Target Milestone: ---

https://github.com/meganz/mingw-std-threads/issues/67

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
@ 2022-11-27 17:56 ` pinskia at gcc dot gnu.org
  2022-11-27 17:58 ` pinskia at gcc dot gnu.org
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-27 17:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Have you tried GCC 12? As C++20 support was barely there for GCC 11.
For an example r12-10-gb52aef3a8cbcc8 improved latch support.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
  2022-11-27 17:56 ` [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 pinskia at gcc dot gnu.org
@ 2022-11-27 17:58 ` pinskia at gcc dot gnu.org
  2022-11-27 18:01 ` lukaszcz18 at wp dot pl
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-27 17:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also it might be the case mingw work is needed to support __cpp_lib_atomic_wait
and all.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
  2022-11-27 17:56 ` [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 pinskia at gcc dot gnu.org
  2022-11-27 17:58 ` pinskia at gcc dot gnu.org
@ 2022-11-27 18:01 ` lukaszcz18 at wp dot pl
  2022-11-27 18:04 ` lukaszcz18 at wp dot pl
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-27 18:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #3 from Jamaika <lukaszcz18 at wp dot pl> ---
(In reply to Andrew Pinski from comment #2)
> Also it might be the case mingw work is needed to support
> __cpp_lib_atomic_wait and all.

I test gcc 13.0.0. No change.
http://msystem.waw.pl/x265/mingw-gcc1300-20221124.7z

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (2 preceding siblings ...)
  2022-11-27 18:01 ` lukaszcz18 at wp dot pl
@ 2022-11-27 18:04 ` lukaszcz18 at wp dot pl
  2022-11-27 18:05 ` lukaszcz18 at wp dot pl
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-27 18:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #4 from Jamaika <lukaszcz18 at wp dot pl> ---
I test gcc 13.0.0. No change

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (3 preceding siblings ...)
  2022-11-27 18:04 ` lukaszcz18 at wp dot pl
@ 2022-11-27 18:05 ` lukaszcz18 at wp dot pl
  2022-11-27 18:12 ` lukaszcz18 at wp dot pl
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-27 18:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #5 from Jamaika <lukaszcz18 at wp dot pl> ---
I test gcc 13.0.0. No change

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (4 preceding siblings ...)
  2022-11-27 18:05 ` lukaszcz18 at wp dot pl
@ 2022-11-27 18:12 ` lukaszcz18 at wp dot pl
  2022-11-27 20:25 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-27 18:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #6 from Jamaika <lukaszcz18 at wp dot pl> ---
I don't understand something. Why _GLIBCXX_HAS_GTHREADS works for std::jthread
but not for std::latch
```
#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX
# define __cpp_lib_atomic_wait 201907L
# if __cpp_aligned_new
# define __cpp_lib_barrier 201907L
# endif
#endif
```

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (5 preceding siblings ...)
  2022-11-27 18:12 ` lukaszcz18 at wp dot pl
@ 2022-11-27 20:25 ` redi at gcc dot gnu.org
  2022-11-28  8:40 ` lukaszcz18 at wp dot pl
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-27 20:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-11-27

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jamaika from comment #0)
> https://github.com/meganz/mingw-std-threads/issues/67

Please read https://gcc.gnu.org/bugs/ and provide the requested info, not just
a URL.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (6 preceding siblings ...)
  2022-11-27 20:25 ` redi at gcc dot gnu.org
@ 2022-11-28  8:40 ` lukaszcz18 at wp dot pl
  2022-11-28  9:21 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-28  8:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #8 from Jamaika <lukaszcz18 at wp dot pl> ---
First lesson on the page https://www.modernescpp.com/index.php/latches-in-c-20
I use GCC from 11.3.1 to 13.0.0 20221124
```
// workers.cpp

#include <iostream>
#include <latch>
#include <mutex>
#include <thread>

std::latch workDone(6);
std::mutex coutMutex;

void synchronizedOut(const std::string& s) {
    std::lock_guard<std::mutex> lo(coutMutex);
    std::cout << s;
}

class Worker {
 public:
    Worker(std::string n): name(n) { };

    void operator() () {
        synchronizedOut(name + ": " + "Work done!\n");
        workDone.arrive_and_wait();  // wait until all work is done  (1)
        synchronizedOut(name + ": " + "See you tomorrow!\n");
    }
 private:
    std::string name;
};

int main() {

    std::cout << '\n';

    Worker herb("  Herb");
    std::thread herbWork(herb);

    Worker scott("    Scott");
    std::thread scottWork(scott);

    Worker bjarne("      Bjarne");
    std::thread bjarneWork(bjarne);

    Worker andrei("        Andrei");
    std::thread andreiWork(andrei);

    Worker andrew("          Andrew");
    std::thread andrewWork(andrew);

    Worker david("            David");
    std::thread davidWork(david);

    herbWork.join();
    scottWork.join();
    bjarneWork.join();
    andreiWork.join();
    andrewWork.join();
    davidWork.join();

}
```
I have error.
workers.cpp:8:6: error: 'latch' in namespace 'std' does not name a type
    8 | std::latch workDone(6);
      |      ^~~~~
When I use 'latch.h' gcc 11.3.0 and above hasn't problem.
https://github.com/luncliff/latch/blob/master/latch.h
I have not error.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (7 preceding siblings ...)
  2022-11-28  8:40 ` lukaszcz18 at wp dot pl
@ 2022-11-28  9:21 ` redi at gcc dot gnu.org
  2022-11-28 11:59 ` lukaszcz18 at wp dot pl
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28  9:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please read https://gcc.gnu.org/bugs/ and provide the requested info!

It asks for several things which are still missing and should not be difficult,
e.g. the output of `gcc -v`

It works fine for me with x86_64-w64-mingw32 so this seems to be a problem with
the mingw config, not with upstream GCC. Probably you don't have a threading
library that GCC can use, such as pthreads-win32. But we can't tell how your
GCC has been configured because you won't provide the requested information.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (8 preceding siblings ...)
  2022-11-28  9:21 ` redi at gcc dot gnu.org
@ 2022-11-28 11:59 ` lukaszcz18 at wp dot pl
  2022-11-28 12:03 ` lukaszcz18 at wp dot pl
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-28 11:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #10 from Jamaika <lukaszcz18 at wp dot pl> ---
```
Using built-in specs.
COLLECT_GCC=g++.exe
Target: x86_64-w64-mingw32
Configured with: /home/ma/m/source/gcc-g/configure --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-nls --enable-languages=c,c++,objc,obj-c++
--with-gmp=/home/ma/m/build/for_target --with-mpfr=/home/ma/m/build/for_target
--with-mpc=/home/ma/m/build/for_target --with-isl=/home/ma/m/build/for_target
--enable-twoprocess --disable-libstdcxx-pch --disable-win32-registry
--disable-shared --enable-fully-dynamic-string --enable-libssp
--prefix=/home/ma/m/target --with-sysroot=/home/ma/m/target
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221124 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-std=gnu++20' '-ftree-vectorize' '-D' 'WINVER=0x0602'
'-D' '_WIN32_WINNT=0x0602' '-g0' '-O3' '-c' '-o' 'latch_windows.o'
'-mtune=generic' '-march=x86-64'
 c:/gcc1300/bin/../libexec/gcc/x86_64-w64-mingw32/13.0.0/cc1plus.exe -quiet -v
-iprefix c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/ -U_REENTRANT -D
WINVER=0x0602 -D _WIN32_WINNT=0x0602 latch_windows.cpp -quiet -dumpbase
latch_windows.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g0 -O3
-std=gnu++20 -version -ftree-vectorize -o
C:\Users\KOMPUT~1\AppData\Local\Temp\ccI5bDpg.s
GNU C++20 (GCC) version 13.0.0 20221124 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 13.0.0 20221124 (experimental), GMP version
6.2.1, MPFR version 4.1.1, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/x86_64-w64-mingw32"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/backward"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/include"
ignoring nonexistent directory
"/home/ma/m/target/home/ma/m/target/lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/include-fixed"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/home/ma/m/target/mingw/include"
#include "..." search starts here:
#include <...> search starts here:

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/x86_64-w64-mingw32

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/backward
 c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/include
 c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/include-fixed

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++20 (GCC) version 13.0.0 20221124 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 13.0.0 20221124 (experimental), GMP version
6.2.1, MPFR version 4.1.1, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 2b6c2fb9839dec486c0793745b5cdfdc
In file included from c:\gcc1300\include\c++\13.0.0\latch:38,
                 from latch_windows.cpp:5:
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::atomic_flag::wait(bool, std::memory_order) const':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:264:12: error:
'__atomic_wait_address_v' is not a member of 'std'
  264 |       std::__atomic_wait_address_v(&_M_i, __v,
      |            ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::atomic_flag::notify_one()':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:272:12: error:
'__atomic_notify_address' is not a member of 'std'
  272 |     { std::__atomic_notify_address(&_M_i, false); }
      |            ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::atomic_flag::notify_all()':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:278:12: error:
'__atomic_notify_address' is not a member of 'std'
  278 |     { std::__atomic_notify_address(&_M_i, true); }
      |            ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::__atomic_base<_IntTp>::wait(__int_type, std::memory_order) const':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:613:14: error:
'__atomic_wait_address_v' is not a member of 'std'
  613 |         std::__atomic_wait_address_v(&_M_i, __old,
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::__atomic_base<_IntTp>::notify_one()':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:621:14: error:
'__atomic_notify_address' is not a member of 'std'
  621 |       { std::__atomic_notify_address(&_M_i, false); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::__atomic_base<_IntTp>::notify_all()':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:627:14: error:
'__atomic_notify_address' is not a member of 'std'
  627 |       { std::__atomic_notify_address(&_M_i, true); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::__atomic_base<_PTp*>::wait(__pointer_type, std::memory_order) const':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:915:14: error:
'__atomic_wait_address_v' is not a member of 'std'
  915 |         std::__atomic_wait_address_v(&_M_p, __old,
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::__atomic_base<_PTp*>::notify_one() const':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:924:14: error:
'__atomic_notify_address' is not a member of 'std'
  924 |       { std::__atomic_notify_address(&_M_p, false); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In member function 'void
std::__atomic_base<_PTp*>::notify_all() const':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:930:14: error:
'__atomic_notify_address' is not a member of 'std'
  930 |       { std::__atomic_notify_address(&_M_p, true); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In function 'void
std::__atomic_impl::wait(const _Tp*, _Val<_Tp>, std::memory_order)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:1092:14: error:
'__atomic_wait_address_v' is not a member of 'std'
 1092 |         std::__atomic_wait_address_v(__ptr, __old,
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In function 'void
std::__atomic_impl::notify_one(const _Tp*)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:1101:14: error:
'__atomic_notify_address' is not a member of 'std'
 1101 |       { std::__atomic_notify_address(__ptr, false); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h: In function 'void
std::__atomic_impl::notify_all(const _Tp*)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:1108:14: error:
'__atomic_notify_address' is not a member of 'std'
 1108 |       { std::__atomic_notify_address(__ptr, true); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\latch: At global scope:
c:\gcc1300\include\c++\13.0.0\latch:90:35: error: '__platform_wait_t' is not a
member of 'std::__detail'
   90 |     alignas(__alignof__(__detail::__platform_wait_t))
__detail::__platform_wait_t _M_a;
      |                                   ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\latch: In static member function 'static
constexpr std::ptrdiff_t std::latch::max()':
c:\gcc1300\include\c++\13.0.0\latch:53:48: error: '__platform_wait_t' is not a
member of 'std::__detail'
   53 |     { return
__gnu_cxx::__int_traits<__detail::__platform_wait_t>::__max; }
      |                                                ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\latch:53:65: error: template argument 1 is
invalid
   53 |     { return
__gnu_cxx::__int_traits<__detail::__platform_wait_t>::__max; }
      |                                                                 ^
c:\gcc1300\include\c++\13.0.0\latch: In constructor 'constexpr
std::latch::latch(std::ptrdiff_t)':
c:\gcc1300\include\c++\13.0.0\latch:56:9: error: class 'std::latch' does not
have any field named '_M_a'
   56 |       : _M_a(__expected) { }
      |         ^~~~
c:\gcc1300\include\c++\13.0.0\latch: In member function 'void
std::latch::count_down(std::ptrdiff_t)':
c:\gcc1300\include\c++\13.0.0\latch:65:52: error: '_M_a' was not declared in
this scope
   65 |       auto const __old = __atomic_impl::fetch_sub(&_M_a,
      |                                                    ^~~~
c:\gcc1300\include\c++\13.0.0\latch: In member function 'bool
std::latch::try_wait() const':
c:\gcc1300\include\c++\13.0.0\latch:73:35: error: '_M_a' was not declared in
this scope
   73 |     { return __atomic_impl::load(&_M_a, memory_order::acquire) == 0; }
      |                                   ^~~~
c:\gcc1300\include\c++\13.0.0\latch: In member function 'void
std::latch::wait() const':
c:\gcc1300\include\c++\13.0.0\latch:79:12: error: '__atomic_wait_address' is
not a member of 'std'
   79 |       std::__atomic_wait_address(&_M_a, __pred);
      |            ^~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\latch:79:35: error: '_M_a' was not declared in
this scope
   79 |       std::__atomic_wait_address(&_M_a, __pred);
      |                                   ^~~~
In file included from c:\gcc1300\include\c++\13.0.0\mutex:60,
                 from latch_windows.cpp:6:
c:\gcc1300\include\c++\13.0.0\atomic: In member function 'void
std::atomic<_Tp>::wait(_Tp, std::memory_order) const':
c:\gcc1300\include\c++\13.0.0\atomic:393:12: error: '__atomic_wait_address_v'
is not a member of 'std'
  393 |       std::__atomic_wait_address_v(&_M_i, __old,
      |            ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic: In member function 'void
std::atomic<_Tp>::notify_one()':
c:\gcc1300\include\c++\13.0.0\atomic:401:12: error: '__atomic_notify_address'
is not a member of 'std'
  401 |     { std::__atomic_notify_address(&_M_i, false); }
      |            ^~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic: In member function 'void
std::atomic<_Tp>::notify_all()':
c:\gcc1300\include\c++\13.0.0\atomic:405:12: error: '__atomic_notify_address'
is not a member of 'std'
  405 |     { std::__atomic_notify_address(&_M_i, true); }
      |            ^~~~~~~~~~~~~~~~~~~~~~~
In file included from c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:38,
                 from c:\gcc1300\include\c++\13.0.0\semaphore:37,
                 from c:\gcc1300\include\c++\13.0.0\stop_token:39,
                 from c:\gcc1300\include\c++\13.0.0\thread:42,
                 from latch_windows.cpp:7:
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: At global scope:
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:199:5: error: expected
class-name before '{' token
  199 |     {
      |     ^
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:203:26: error:
'__platform_wait_t' has not been declared
  203 |         _M_do_wait_until(__platform_wait_t* __addr, __platform_wait_t
__old,
      |                          ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:203:53: error:
'__platform_wait_t' has not been declared
  203 |         _M_do_wait_until(__platform_wait_t* __addr, __platform_wait_t
__old,
      |                                                     ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In member function
'bool std::__detail::__timed_waiter_pool::_M_do_wait_until(int*, int, const
std::chrono::time_point<_Clock, _Duration1>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:209:11: error:
'__platform_wait_t' was not declared in this scope
  209 |           __platform_wait_t __val;
      |           ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:210:34: error: '__val'
was not declared in this scope
  210 |           __atomic_load(__addr, &__val, __ATOMIC_RELAXED);
      |                                  ^~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:210:24: error: argument
2 of '__atomic_load' must be a pointer type
  210 |           __atomic_load(__addr, &__val, __ATOMIC_RELAXED);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:213:37: error: '_M_mtx'
was not declared in this scope
  213 |               lock_guard<mutex> __l(_M_mtx);
      |                                     ^~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:214:40: error: '_M_cv'
was not declared in this scope
  214 |               return __cond_wait_until(_M_cv, _M_mtx, __atime);
      |                                        ^~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In member function
'bool std::__detail::__timed_backoff_spin_policy::operator()() const':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:257:13: error:
'__thread_yield' was not declared in this scope; did you mean '__threadid'?
  257 |             __thread_yield();
      |             ^~~~~~~~~~~~~~
      |             __threadid
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: At global scope:
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:44: error: expected
template-name before '<' token
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |                                            ^
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:44: error: expected
'{' before '<' token
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In function 'bool
std::__atomic_wait_address_until_v(const _Tp*, _Tp&&, _ValFn&&, const
chrono::time_point<_Clock, _Dur2>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:391:37: error: '__w' has
incomplete type
  391 |       __detail::__enters_timed_wait __w{__addr};
      |                                     ^~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:14: note:
declaration of 'using std::__detail::__enters_timed_wait = struct
std::__detail::__timed_waiter<std::integral_constant<bool, true> >'
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |              ^~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In function 'bool
std::__atomic_wait_address_until(const _Tp*, _Pred, const
chrono::time_point<_Clock, _Dur2>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:402:37: error: '__w' has
incomplete type
  402 |       __detail::__enters_timed_wait __w{__addr};
      |                                     ^~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:14: note:
declaration of 'using std::__detail::__enters_timed_wait = struct
std::__detail::__timed_waiter<std::integral_constant<bool, true> >'
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |              ^~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: At global scope:
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:409:54: error:
'__platform_wait_t' in namespace 'std::__detail' does not name a type
  409 |     __atomic_wait_address_until_bare(const __detail::__platform_wait_t*
__addr,
      |                                                      ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In function 'bool
std::__atomic_wait_address_until_bare(const int*, _Pred, const
chrono::time_point<_Clock, _Dur>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:414:35: error: '__w' has
incomplete type
  414 |       __detail::__bare_timed_wait __w{__addr};
      |                                   ^~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:14: note:
declaration of 'using std::__detail::__bare_timed_wait = struct
std::__detail::__timed_waiter<std::integral_constant<bool, false> >'
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |              ^~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In function 'bool
std::__atomic_wait_address_for_v(const _Tp*, _Tp&&, _ValFn&&, const
chrono::duration<_Rep2, _Period2>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:424:37: error: '__w' has
incomplete type
  424 |       __detail::__enters_timed_wait __w{__addr};
      |                                     ^~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:14: note:
declaration of 'using std::__detail::__enters_timed_wait = struct
std::__detail::__timed_waiter<std::integral_constant<bool, true> >'
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |              ^~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In function 'bool
std::__atomic_wait_address_for(const _Tp*, _Pred, const chrono::duration<_Rep2,
_Period2>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:435:37: error: '__w' has
incomplete type
  435 |       __detail::__enters_timed_wait __w{__addr};
      |                                     ^~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:14: note:
declaration of 'using std::__detail::__enters_timed_wait = struct
std::__detail::__timed_waiter<std::integral_constant<bool, true> >'
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |              ^~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: At global scope:
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:442:52: error:
'__platform_wait_t' in namespace 'std::__detail' does not name a type
  442 |     __atomic_wait_address_for_bare(const __detail::__platform_wait_t*
__addr,
      |                                                    ^~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h: In function 'bool
std::__atomic_wait_address_for_bare(const int*, _Pred, const
chrono::duration<_Rep, _Period>&)':
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:446:35: error: '__w' has
incomplete type
  446 |       __detail::__bare_timed_wait __w{__addr};
      |                                   ^~~
c:\gcc1300\include\c++\13.0.0\bits\atomic_timed_wait.h:266:14: note:
declaration of 'using std::__detail::__bare_timed_wait = struct
std::__detail::__timed_waiter<std::integral_constant<bool, false> >'
  266 |       struct __timed_waiter : __waiter_base<__timed_waiter_pool>
      |              ^~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: At global scope:
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:188:60: error: expected ')'
before '__count'
  188 |     explicit __atomic_semaphore(__detail::__platform_wait_t __count)
noexcept
      |                                ~                           ^~~~~~~~
      |                                                            )
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:198:23: error:
'std::__detail::__platform_wait_t' has not been declared
  198 |     _S_do_try_acquire(__detail::__platform_wait_t* __counter) noexcept
      |                       ^~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:262:23: error:
'__platform_wait_alignment' is not a member of 'std::__detail'
  262 |     alignas(__detail::__platform_wait_alignment)
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In lambda function:
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:214:50: error: 'struct
std::__atomic_semaphore' has no member named '_M_counter'
  214 |         [this] { return _S_do_try_acquire(&this->_M_counter); };
      |                                                  ^~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In member function 'void
std::__atomic_semaphore::_M_acquire()':
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:215:12: error:
'__atomic_wait_address_bare' is not a member of 'std'; did you mean
'__atomic_wait_address_for'?
  215 |       std::__atomic_wait_address_bare(&_M_counter, __pred);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |            __atomic_wait_address_for
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:215:40: error: '_M_counter'
was not declared in this scope; did you mean 'PMCCounter'?
  215 |       std::__atomic_wait_address_bare(&_M_counter, __pred);
      |                                        ^~~~~~~~~~
      |                                        PMCCounter
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In lambda function:
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:222:50: error: 'struct
std::__atomic_semaphore' has no member named '_M_counter'
  222 |         [this] { return _S_do_try_acquire(&this->_M_counter); };
      |                                                  ^~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In member function 'bool
std::__atomic_semaphore::_M_try_acquire()':
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:223:29: error:
'__atomic_spin' is not a member of 'std::__detail'
  223 |       return std::__detail::__atomic_spin(__pred);
      |                             ^~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In lambda function:
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:232:52: error: 'struct
std::__atomic_semaphore' has no member named '_M_counter'
  232 |           [this] { return _S_do_try_acquire(&this->_M_counter); };
      |                                                    ^~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In member function 'bool
std::__atomic_semaphore::_M_try_acquire_until(const
std::chrono::time_point<_Clock, _Duration1>&)':
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:234:50: error: '_M_counter'
was not declared in this scope; did you mean 'PMCCounter'?
  234 |         return __atomic_wait_address_until_bare(&_M_counter, __pred,
__atime);
      |                                                  ^~~~~~~~~~
      |                                                  PMCCounter
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In lambda function:
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:243:52: error: 'struct
std::__atomic_semaphore' has no member named '_M_counter'
  243 |           [this] { return _S_do_try_acquire(&this->_M_counter); };
      |                                                    ^~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In member function 'bool
std::__atomic_semaphore::_M_try_acquire_for(const std::chrono::duration<_Rep1,
_Period1>&)':
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:245:48: error: '_M_counter'
was not declared in this scope; did you mean 'PMCCounter'?
  245 |         return __atomic_wait_address_for_bare(&_M_counter, __pred,
__rtime);
      |                                                ^~~~~~~~~~
      |                                                PMCCounter
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h: In member function 'void
std::__atomic_semaphore::_M_release(std::ptrdiff_t)':
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:251:41: error: '_M_counter'
was not declared in this scope; did you mean 'PMCCounter'?
  251 |       if (0 < __atomic_impl::fetch_add(&_M_counter, __update,
memory_order_release))
      |                                         ^~~~~~~~~~
      |                                         PMCCounter
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:254:39: error: '_M_counter'
was not declared in this scope; did you mean 'PMCCounter'?
  254 |         __atomic_notify_address_bare(&_M_counter, true);
      |                                       ^~~~~~~~~~
      |                                       PMCCounter
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:254:9: error:
'__atomic_notify_address_bare' was not declared in this scope; did you mean
'__atomic_wait_address_for'?
  254 |         __atomic_notify_address_bare(&_M_counter, true);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         __atomic_wait_address_for
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:256:39: error: '_M_counter'
was not declared in this scope; did you mean 'PMCCounter'?
  256 |         __atomic_notify_address_bare(&_M_counter, true);
      |                                       ^~~~~~~~~~
      |                                       PMCCounter
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:256:9: error:
'__atomic_notify_address_bare' was not declared in this scope; did you mean
'__atomic_wait_address_for'?
  256 |         __atomic_notify_address_bare(&_M_counter, true);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         __atomic_wait_address_for
c:\gcc1300\include\c++\13.0.0\semaphore: In instantiation of
'std::counting_semaphore<__least_max_value>::counting_semaphore(std::ptrdiff_t)
[with long long int __least_max_value = 1; std::ptrdiff_t = long long int]':
c:\gcc1300\include\c++\13.0.0\stop_token:141:33:   required from here
c:\gcc1300\include\c++\13.0.0\semaphore:56:18: error: cannot convert
'std::ptrdiff_t' {aka 'long long int'} to 'const std::__atomic_semaphore&'
   56 |         : _M_sem(__desired)
      |                  ^~~~~~~~~
      |                  |
      |                  std::ptrdiff_t {aka long long int}
c:\gcc1300\include\c++\13.0.0\bits\semaphore_base.h:194:24: note:  
initializing argument 1 of 'std::__atomic_semaphore::__atomic_semaphore(const
std::__atomic_semaphore&)'
  194 |     __atomic_semaphore(const __atomic_semaphore&) = delete;
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~
```

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (9 preceding siblings ...)
  2022-11-28 11:59 ` lukaszcz18 at wp dot pl
@ 2022-11-28 12:03 ` lukaszcz18 at wp dot pl
  2022-11-28 12:05 ` lukaszcz18 at wp dot pl
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-28 12:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #11 from Jamaika <lukaszcz18 at wp dot pl> ---
without #define __cpp_lib_atomic_wait 201907L
```
Using built-in specs.
COLLECT_GCC=g++.exe
Target: x86_64-w64-mingw32
Configured with: /home/ma/m/source/gcc-g/configure --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-nls --enable-languages=c,c++,objc,obj-c++
--with-gmp=/home/ma/m/build/for_target --with-mpfr=/home/ma/m/build/for_target
--with-mpc=/home/ma/m/build/for_target --with-isl=/home/ma/m/build/for_target
--enable-twoprocess --disable-libstdcxx-pch --disable-win32-registry
--disable-shared --enable-fully-dynamic-string --enable-libssp
--prefix=/home/ma/m/target --with-sysroot=/home/ma/m/target
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221124 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-std=gnu++20' '-ftree-vectorize' '-D' 'WINVER=0x0602'
'-D' '_WIN32_WINNT=0x0602' '-g0' '-O3' '-c' '-o' 'latch_windows.o'
'-mtune=generic' '-march=x86-64'
 c:/gcc1300/bin/../libexec/gcc/x86_64-w64-mingw32/13.0.0/cc1plus.exe -quiet -v
-iprefix c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/ -U_REENTRANT -D
WINVER=0x0602 -D _WIN32_WINNT=0x0602 latch_windows.cpp -quiet -dumpbase
latch_windows.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g0 -O3
-std=gnu++20 -version -ftree-vectorize -o
C:\Users\KOMPUT~1\AppData\Local\Temp\ccVi63tF.s
GNU C++20 (GCC) version 13.0.0 20221124 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 13.0.0 20221124 (experimental), GMP version
6.2.1, MPFR version 4.1.1, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/x86_64-w64-mingw32"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/backward"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/include"
ignoring nonexistent directory
"/home/ma/m/target/home/ma/m/target/lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/include-fixed"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/home/ma/m/target/mingw/include"
#include "..." search starts here:
#include <...> search starts here:

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/x86_64-w64-mingw32

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/backward
 c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/include
 c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/include-fixed

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++20 (GCC) version 13.0.0 20221124 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 13.0.0 20221124 (experimental), GMP version
6.2.1, MPFR version 4.1.1, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 2b6c2fb9839dec486c0793745b5cdfdc
latch_windows.cpp:9:6: error: 'latch' in namespace 'std' does not name a type
    9 | std::latch workDone(6);
      |      ^~~~~
latch_windows.cpp: In member function 'void Worker::operator()()':
latch_windows.cpp:23:9: error: 'workDone' was not declared in this scope
   23 |         workDone.arrive_and_wait();  // wait until all work is done 
(1)
      |         ^~~~~~~~
```

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (10 preceding siblings ...)
  2022-11-28 12:03 ` lukaszcz18 at wp dot pl
@ 2022-11-28 12:05 ` lukaszcz18 at wp dot pl
  2022-11-28 15:58 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-28 12:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #12 from Jamaika <lukaszcz18 at wp dot pl> ---
with 'latch.h'
```
Using built-in specs.
COLLECT_GCC=g++.exe
Target: x86_64-w64-mingw32
Configured with: /home/ma/m/source/gcc-g/configure --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-nls --enable-languages=c,c++,objc,obj-c++
--with-gmp=/home/ma/m/build/for_target --with-mpfr=/home/ma/m/build/for_target
--with-mpc=/home/ma/m/build/for_target --with-isl=/home/ma/m/build/for_target
--enable-twoprocess --disable-libstdcxx-pch --disable-win32-registry
--disable-shared --enable-fully-dynamic-string --enable-libssp
--prefix=/home/ma/m/target --with-sysroot=/home/ma/m/target
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221124 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-std=gnu++20' '-ftree-vectorize' '-D' 'WINVER=0x0602'
'-D' '_WIN32_WINNT=0x0602' '-g0' '-O3' '-c' '-o' 'latch_windows.o'
'-mtune=generic' '-march=x86-64'
 c:/gcc1300/bin/../libexec/gcc/x86_64-w64-mingw32/13.0.0/cc1plus.exe -quiet -v
-iprefix c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/ -U_REENTRANT -D
WINVER=0x0602 -D _WIN32_WINNT=0x0602 latch_windows.cpp -quiet -dumpbase
latch_windows.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g0 -O3
-std=gnu++20 -version -ftree-vectorize -o
C:\Users\KOMPUT~1\AppData\Local\Temp\cc7P0VYd.s
GNU C++20 (GCC) version 13.0.0 20221124 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 13.0.0 20221124 (experimental), GMP version
6.2.1, MPFR version 4.1.1, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/x86_64-w64-mingw32"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/backward"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/include"
ignoring nonexistent directory
"/home/ma/m/target/home/ma/m/target/lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/include-fixed"
ignoring duplicate directory
"c:/gcc1300/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/home/ma/m/target/mingw/include"
#include "..." search starts here:
#include <...> search starts here:

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/x86_64-w64-mingw32

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../include/c++/13.0.0/backward
 c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/include
 c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/include-fixed

c:\gcc1300\bin\../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++20 (GCC) version 13.0.0 20221124 (experimental) (x86_64-w64-mingw32)
        compiled by GNU C version 13.0.0 20221124 (experimental), GMP version
6.2.1, MPFR version 4.1.1, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 2b6c2fb9839dec486c0793745b5cdfdc
COLLECT_GCC_OPTIONS='-v' '-std=gnu++20' '-ftree-vectorize' '-D' 'WINVER=0x0602'
'-D' '_WIN32_WINNT=0x0602' '-g0' '-O3' '-c' '-o' 'latch_windows.o'
'-mtune=generic' '-march=x86-64'

c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/bin/as.exe
-v -o latch_windows.o C:\Users\KOMPUT~1\AppData\Local\Temp\cc7P0VYd.s
GNU assembler version 2.39 (x86_64-w64-mingw32) using BFD version (GNU
Binutils) 2.39
COMPILER_PATH=c:/gcc1300/bin/../libexec/gcc/x86_64-w64-mingw32/13.0.0/;c:/gcc1300/bin/../libexec/gcc/;c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/;c:/gcc1300/bin/../lib/gcc/;c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/lib/../lib/;c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../lib/;c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../../x86_64-w64-mingw32/lib/;c:/gcc1300/bin/../lib/gcc/x86_64-w64-mingw32/13.0.0/../../../
COLLECT_GCC_OPTIONS='-v' '-std=gnu++20' '-ftree-vectorize' '-D' 'WINVER=0x0602'
'-D' '_WIN32_WINNT=0x0602' '-g0' '-O3' '-c' '-o' 'latch_windows.o'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'latch_windows.'
```

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (11 preceding siblings ...)
  2022-11-28 12:05 ` lukaszcz18 at wp dot pl
@ 2022-11-28 15:58 ` redi at gcc dot gnu.org
  2022-11-28 16:03 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28 15:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jamaika from comment #6)
> I don't understand something. Why _GLIBCXX_HAS_GTHREADS works for
> std::jthread but not for std::latch

std::jthread doesn't depend on _GLIBCXX_HAS_GTHREADS, it's always available.
But you might not be able to create a new thread using std::jthread if your
platform doesn't provide what's needed for it to work.

(In reply to Jamaika from comment #10)
> ```
> Using built-in specs.
> COLLECT_GCC=g++.exe
> Target: x86_64-w64-mingw32
> Configured with: /home/ma/m/source/gcc-g/configure --host=x86_64-w64-mingw32
> --target=x86_64-w64-mingw32 --disable-nls
> --enable-languages=c,c++,objc,obj-c++ --with-gmp=/home/ma/m/build/for_target
> --with-mpfr=/home/ma/m/build/for_target
> --with-mpc=/home/ma/m/build/for_target
> --with-isl=/home/ma/m/build/for_target --enable-twoprocess
> --disable-libstdcxx-pch --disable-win32-registry --disable-shared
> --enable-fully-dynamic-string --enable-libssp --prefix=/home/ma/m/target
> --with-sysroot=/home/ma/m/target
> Thread model: win32

This is the problem. You need a thread model that provides the support needed
for C++.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (12 preceding siblings ...)
  2022-11-28 15:58 ` redi at gcc dot gnu.org
@ 2022-11-28 16:03 ` redi at gcc dot gnu.org
  2022-11-28 16:09 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28 16:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jamaika from comment #11)
> without #define __cpp_lib_atomic_wait 201907L

You should not be defining this anyway, it's defined by the library when the
feature is supported. You can't change that. Don't ever define these __cpp_*
macros.


(In reply to Jamaika from comment #12)
> with 'latch.h'

This is a third-party header that defines its own std::latch, it has nothing to
do with GCC.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (13 preceding siblings ...)
  2022-11-28 16:03 ` redi at gcc dot gnu.org
@ 2022-11-28 16:09 ` redi at gcc dot gnu.org
  2022-11-28 16:29 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28 16:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirming, as we might be able to support some subset of C++20 concurrency
primitives for the Win32 model. As
https://github.com/luncliff/latch/blob/master/latch_windows.cpp shows all
that's needed are atomic decrements and WaitOnAddress/WakeByAddressAll.

If our std::__atomic_wait_address and __atomic_impl::notify_all used those, we
could provide std::latch, and maybe others.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (14 preceding siblings ...)
  2022-11-28 16:09 ` redi at gcc dot gnu.org
@ 2022-11-28 16:29 ` redi at gcc dot gnu.org
  2022-11-28 18:05 ` lukaszcz18 at wp dot pl
  2023-01-17 19:36 ` i.nixman at autistici dot org
  17 siblings, 0 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-28 16:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Something like ...

--- include/bits/atomic_wait.h  2022-11-07 15:38:32.551751184 +0000
+++ /tmp/inc/bits/atomic_wait.h 2022-11-28 16:27:51.352489618 +0000
@@ -33,7 +33,7 @@
 #pragma GCC system_header

 #include <bits/c++config.h>
-#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX
+#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX ||
_WIN32
 #include <bits/functional_hash.h>
 #include <bits/gthr.h>
 #include <ext/numeric_traits.h>
@@ -59,6 +59,10 @@
 #define _GLIBCXX_HAVE_PLATFORM_WAIT 1
     using __platform_wait_t = int;
     inline constexpr size_t __platform_wait_alignment = 4;
+#elif _WIN32
+    using __platform_wait_t = __UINTPTR_TYPE__;
+    inline constexpr size_t __platform_wait_alignment
+      = alignof(__platform_wait_t);
 #else
 // define _GLIBCX_HAVE_PLATFORM_WAIT and implement __platform_wait()
 // and __platform_notify() if there is a more efficient primitive supported
@@ -122,6 +126,30 @@
                 static_cast<int>(__futex_wait_flags::__wake_private),
                 __all ? INT_MAX : 1);
       }
+#elif _WIN32
+    extern "C" int __glibcxx_get_last_error() __asm("GetLastError");
+
+    template<typename _Tp>
+      void
+      __platform_wait(const _Tp* __addr, __platform_wait_t __val) noexcept
+      {
+        const long __timeout = 0xffffffff;
+       if (WaitOnAddress(__addr, &__val, sizeof(__platform_wait_t),
__timeout))
+         return;
+        _GLIBCXX_THROW_OR_ABORT(std::system_error(__glibcxx_get_last_error(),
+                                                 std::system_category(),
+                                                 "WaitOnAddress"));
+      }
+
+    template<typename _Tp>
+      void
+      __platform_notify(const _Tp* __addr, bool __all) noexcept
+      {
+       if (__all)
+         WakeByAddressAll(__addr);
+       else
+         WakeByAddressOne(__addr);
+      }
 #endif

     inline void

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (15 preceding siblings ...)
  2022-11-28 16:29 ` redi at gcc dot gnu.org
@ 2022-11-28 18:05 ` lukaszcz18 at wp dot pl
  2023-01-17 19:36 ` i.nixman at autistici dot org
  17 siblings, 0 replies; 19+ messages in thread
From: lukaszcz18 at wp dot pl @ 2022-11-28 18:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #17 from Jamaika <lukaszcz18 at wp dot pl> ---
Testing atomic_wait, errors are still there. Thanks for taking up the topic.
```
In file included from c:\gcc1300\include\c++\13.0.0\mutex:60,
                 from c:\gcc1300\include\c++\13.0.0\bits\atomic_wait.h:49,
                 from c:\gcc1300\include\c++\13.0.0\bits\atomic_base.h:42,
                 from c:\gcc1300\include\c++\13.0.0\latch:38,
                 from latch_windows.cpp:4:
c:\gcc1300\include\c++\13.0.0\atomic:67:5: error: '__atomic_base' does not name
a type
   67 |     __atomic_base<bool> _M_base;
      |     ^~~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic:103:21: error: 'memory_order' has not been
declared
  103 |     store(bool __i, memory_order __m = memory_order_seq_cst) noexcept
      |                     ^~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic:107:21: error: 'memory_order' has not been
declared
  107 |     store(bool __i, memory_order __m = memory_order_seq_cst) volatile
noexcept
      |                     ^~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic:111:10: error: 'memory_order' has not been
declared
  111 |     load(memory_order __m = memory_order_seq_cst) const noexcept
      |          ^~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic:115:10: error: 'memory_order' has not been
declared
  115 |     load(memory_order __m = memory_order_seq_cst) const volatile
noexcept
      |          ^~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic:119:24: error: 'memory_order' has not been
declared
  119 |     exchange(bool __i, memory_order __m = memory_order_seq_cst)
noexcept
      |                        ^~~~~~~~~~~~
c:\gcc1300\include\c++\13.0.0\atomic:124:14: error: 'memory_order' has not been
declared
  124 |              memory_order __m = memory_order_seq_cst) volatile noexcept
      |              ^~~~~~~~~~~~
```

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20
  2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
                   ` (16 preceding siblings ...)
  2022-11-28 18:05 ` lukaszcz18 at wp dot pl
@ 2023-01-17 19:36 ` i.nixman at autistici dot org
  17 siblings, 0 replies; 19+ messages in thread
From: i.nixman at autistici dot org @ 2023-01-17 19:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #18 from niXman <i.nixman at autistici dot org> ---
Created attachment 54291
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54291&action=edit
confirmation

it works for me. please look at attachment screenshot.

for GCC-master, configured as x86_64-w64-mingw32, threads=win32.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-01-17 19:36 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-27 17:52 [Bug c++/107886] New: Problem witch std::latch, std::binary_semaphores in C++2a lukaszcz18 at wp dot pl
2022-11-27 17:56 ` [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 pinskia at gcc dot gnu.org
2022-11-27 17:58 ` pinskia at gcc dot gnu.org
2022-11-27 18:01 ` lukaszcz18 at wp dot pl
2022-11-27 18:04 ` lukaszcz18 at wp dot pl
2022-11-27 18:05 ` lukaszcz18 at wp dot pl
2022-11-27 18:12 ` lukaszcz18 at wp dot pl
2022-11-27 20:25 ` redi at gcc dot gnu.org
2022-11-28  8:40 ` lukaszcz18 at wp dot pl
2022-11-28  9:21 ` redi at gcc dot gnu.org
2022-11-28 11:59 ` lukaszcz18 at wp dot pl
2022-11-28 12:03 ` lukaszcz18 at wp dot pl
2022-11-28 12:05 ` lukaszcz18 at wp dot pl
2022-11-28 15:58 ` redi at gcc dot gnu.org
2022-11-28 16:03 ` redi at gcc dot gnu.org
2022-11-28 16:09 ` redi at gcc dot gnu.org
2022-11-28 16:29 ` redi at gcc dot gnu.org
2022-11-28 18:05 ` lukaszcz18 at wp dot pl
2023-01-17 19:36 ` i.nixman at autistici dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).