-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<chrono>
: Fix formatting for unusual duration
s
#3649
<chrono>
: Fix formatting for unusual duration
s
#3649
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Currently no implementation correctly formats However, it seems that [time.format] doesn't say |
Wait, actually, I'm trying to understand the UB here... could you write up an example? |
I attempted to test formatting Reduced example that contains needed runtime operations and fails to compile due to integer overflow (Godbolt link): #include <chrono>
#include <cstdint>
#include <limits>
#include <ratio>
#include <type_traits>
using LongRatio = std::ratio<INT64_MAX - 1, INT64_MAX>;
using D = std::chrono::duration<int, LongRatio>;
constexpr auto weird40 = D{40};
constexpr auto cast_to_day = std::chrono::duration_cast<std::chrono::days>(weird40);
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Thanks! I pushed a conflict-free merge with |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
We forgot to defend |
Thanks for investigating and fixing this bug! ⌚ 🎉 😸 |
Fixes #3644.
hh_mm_ss<_Duration>
seems wrong for_Hh_mm_ss_part_underflow_to_zero
to me.Need to explore how to accept
duration<I, ratio<9223372036854775806, 9223372036854775807>>
. Currently libstdc++ rejects it, while libc++ accepts it (Godbolt link).Edit: the current approach for calculation of
hh_mm_ss<D>::fractional_width
doesn't seem right. I'm trying to fix it.Edit 2: now the formatting is made well-formed, but UB may happen.