From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 12C263858D3C; Mon, 28 Nov 2022 08:40:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12C263858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669624845; bh=yQUMGkC44lBTcpnm7XXTnxZCJccYZVxPMFWQPkpGupk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TTDcSO18E7iwQ5BJ41bU8DlT75+sbRcN0OKmZR9x2VkXYznjfR4wgEkaHTdc3q3qg JWHWSttlNp0NUJPlhXFQijWxcZUqfMMk1V56MrykbcbQT7/9kGLOugLEY6f16JmWk7 G1OziLg8mTtX6QZfgIhPJbmctTBsj+PT8VeHeYeo= From: "lukaszcz18 at wp dot pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107886] Problem witch std::latch, std::binary_semaphores in C++20 Date: Mon, 28 Nov 2022 08:40:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lukaszcz18 at wp dot pl X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107886 --- Comment #8 from Jamaika --- 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 #include #include #include std::latch workDone(6); std::mutex coutMutex; void synchronizedOut(const std::string& s) { std::lock_guard 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.=