[libcxx-commits] [PATCH] D138826: [libc++][chrono] Fixes formatter duration.

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 10 16:42:44 PDT 2023


EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

This is a better state of the world for sure. I still think there may be ways to do better, but perfect is the enemy of progress, so let's progress for now and think about perfect later.



================
Comment at: libcxx/test/std/time/time.syn/formatter.duration.pass.cpp:1089
+  check(SV("06:20:44.415"), SV("{:%T}"), std::chrono::milliseconds{0x0000'fff'ffff'ffffll}); // 45 bit signed value max
+  check(SV("01:53:03"), SV("{:%T}"), std::chrono::seconds{0x0000'0003'ffff'ffffll});         // 35 bit signed value max
+  check(SV("12:15:00"), SV("{:%T}"), std::chrono::minutes{0x0fff'ffff});                     // 29 bit signed value max
----------------
Mordante wrote:
> EricWF wrote:
> > Can't we just use `std::chrono::years::max`?
> > 
> > Do these test cases fail before your fixes? It looks to me that they're actively avoiding constructing test values that will overflow.
> These tests test the Standard mandated limits as stated by the comment on line 1081. Using larger values will make the tests non-portable.
Right, but it's important we don't introduce UB if a user violates the limits (which they will). 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138826/new/

https://reviews.llvm.org/D138826



More information about the libcxx-commits mailing list