[libcxx-commits] [PATCH] D134742: [libc++][chrono] Implements formatter duration.
Eric Fiselier via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Oct 30 16:31:18 PDT 2022
EricWF reopened this revision.
EricWF added a comment.
This revision is now accepted and ready to land.
Please fix the undefined behavior mentioned above.
================
Comment at: libcxx/include/__chrono/convert_to_tm.h:43
+ // day elapsed since midnight.
+ uint64_t __sec = chrono::duration_cast<chrono::seconds>(__value).count();
+ __sec %= 24 * 3600;
----------------
Does this not overflow for a lot of things?
Like `hours(duration_cast<hours>(seconds::max()) + hours(1))`?
Instead of reverting to raw arithmetic on ints, use chrono to get the values you want.
See https://godbolt.org/z/GYc7Tzn9W
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134742/new/
https://reviews.llvm.org/D134742
More information about the libcxx-commits
mailing list