From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 79515386F836; Fri, 5 Mar 2021 09:58:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79515386F836 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99403] New: Add header fix-it hints for std::this_thread::* and std::jthread Date: Fri, 05 Mar 2021 09:58:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Mar 2021 09:58:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99403 Bug ID: 99403 Summary: Add header fix-it hints for std::this_thread::* and std::jthread Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: diagnostic Severity: enhancement Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include #include int main() { std::this_thread::sleep_for(std::chrono::seconds(1)); std::this_thread::sleep_until(std::chrono::system_clock::now()); std::this_thread::get_id(); std::this_thread::yield(); } This fails with: ns.C: In function 'int main()': ns.C:5:21: error: 'sleep_for' is not a member of 'std::this_thread' 5 | std::this_thread::sleep_for(std::chrono::seconds(1)); | ^~~~~~~~~ ns.C:6:21: error: 'sleep_until' is not a member of 'std::this_thread' 6 | std::this_thread::sleep_until(std::chrono::system_clock::now()); | ^~~~~~~~~~~ We have a fix-it hint for std::thread, but not the other entities in : ns.C:2:1: note: 'std::thread' is defined in header ''; did you forg= et to '#include '? 1 | #include +++ |+#include 2 | int main() That should be added for std::jthread (since C++20 only), and namespace std::this_thread and the four functions in the example above (all for C++11= and later). There is no error for get_id and yield because they happen to be transitively included via , but that's an implementation detail that could change in future (no pun intended). If isn't included we get errors for std::this_thread itself, so th= at nested namespace deserves a fix-it hint of its own: #include int main() { std::this_thread::sleep_for(std::chrono::seconds(1)); } ns.C: In function 'int main()': ns.C:4:8: error: 'std::this_thread' has not been declared 4 | std::this_thread::sleep_for(std::chrono::seconds(1)); | ^~~~~~~~~~~=