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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please provide the code here, not just as a compiler explorer URL:

#include <chrono>
#include <cassert>
#include <iostream>

int main() {
    using file_timepoint = std::chrono::file_time<std::chrono::nanoseconds>;

    const auto min =
file_timepoint{std::chrono::nanoseconds{std::numeric_limits<long int>::min()}};
    const auto zero = file_timepoint{std::chrono::seconds{0}};
    const auto highest_working =
std::chrono::file_time<std::chrono::nanoseconds>{std::chrono::seconds{2785708036}
+ std::chrono::nanoseconds{854775807}};
    const auto first_after_wrap =
file_timepoint{std::chrono::seconds{2785708036} +
std::chrono::nanoseconds{854775808}};
    const auto max =
file_timepoint{std::chrono::nanoseconds{std::numeric_limits<long int>::max()}};

    // these values are properly ordered and has proper values
    // notice that max value, has same low 12 decimal digits identical to last
working
    std::cout << min.time_since_epoch().count() << "\n";
    std::cout << zero.time_since_epoch().count() << "\n";
    std::cout << highest_working.time_since_epoch().count() << "\n";
    std::cout << first_after_wrap.time_since_epoch().count() << "\n";
    std::cout << max.time_since_epoch().count() << "\n";

    // notice the nanosecond part of the formatting is correct, so the wrap
must happen in formatting date + hh::mm::ss only
    std::cout << "  highest working = " << highest_working << "\n";
    std::cout << " first after wrap = " << first_after_wrap << "\n";
    std::cout << "              min = " << min << "\n";
    std::cout << "             zero = " << zero << "\n";
    std::cout << "              max = " << max << "\n";
}


I think this is a dup of Bug 111163 - ubsan shows three signed overflows.

*** This bug has been marked as a duplicate of bug 111163 ***

Reply via email to