Skip to content

Commit

Permalink
trigger undefined behaviour with NaN durations
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldreik committed May 5, 2019
1 parent 7cce332 commit b059a98
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/chrono-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,14 @@ TEST(ChronoTest, NegativeDuration) {
EXPECT_EQ("-00:01", fmt::format("{:%M:%S}", std::chrono::duration<double>(-1)));
}

TEST(ChronoTest, DurationIsFloatNaN) {
const std::chrono::duration<float> d{std::nanf("1")};
auto ignored=fmt::format("{:%I}",d);
}

TEST(ChronoTest, DurationIsDoubleNaN) {
const std::chrono::duration<double> d{std::nan("1")};
auto ignored=fmt::format("{:%I}",d);
}

#endif // FMT_STATIC_THOUSANDS_SEPARATOR

0 comments on commit b059a98

Please sign in to comment.