[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug libstdc++/95992] chrono adding duration to time_point reports signed integer overflow with -fsa
From: "redi at gcc dot gnu.org" <gcc-bugzilla () gcc ! gnu ! org>
Date: 2020-06-30 23:18:01
Message-ID: bug-95992-4-iHc5UcSSVI () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95992
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't think there's any bug here. Libstdc++ uses nanoseconds for
chrono::system_clock::duration, but libc++ uses microseconds.
If you replace system_clock with high_resolution_clock you get the same error
with both libstdc++ and libc++, and the reason is that 9 billion seconds cannot
be represented in nanoseconds.
You need to use more suitable types for the durations you're trying to deal
with, e.g.
using duration_t = std::chrono::microseconds;
void test() {
std::chrono::time_point<std::chrono::system_clock, duration_t> tp;=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic