public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/113327] New: std::sleep_for(std::chrono::hours::max()) returns immediately
@ 2024-01-11  7:24 fchelnokov at gmail dot com
  2024-01-13  0:17 ` [Bug libstdc++/113327] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2024-01-11  7:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113327
           Summary: std::sleep_for(std::chrono::hours::max()) returns
                    immediately
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

Found in https://stackoverflow.com/a/77795017/7325599

The problem is that the following program returns immediately (instead of long
wait):


#include <chrono>
#include <thread>
#include <iostream>

int main(int argc, char * argv[])
{
    std::this_thread::sleep_for(std::chrono::hours::max());
}


Online demo: https://godbolt.org/z/vce44vjx5

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

* [Bug libstdc++/113327] std::sleep_for(std::chrono::hours::max()) returns immediately
  2024-01-11  7:24 [Bug libstdc++/113327] New: std::sleep_for(std::chrono::hours::max()) returns immediately fchelnokov at gmail dot com
@ 2024-01-13  0:17 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-13  0:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Converting hours::max() to milliseconds overflows and produces a negative
value.

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

end of thread, other threads:[~2024-01-13  0:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  7:24 [Bug libstdc++/113327] New: std::sleep_for(std::chrono::hours::max()) returns immediately fchelnokov at gmail dot com
2024-01-13  0:17 ` [Bug libstdc++/113327] " redi at gcc dot gnu.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).