Open Roman-Koshelev opened 2 years ago
I presume you're referring to civil_from_days
. I should change that to match what is actually in date.h:
https://github.com/HowardHinnant/date/blob/master/include/date/date.h#L3101
I just ran this:
int
main()
{
for (auto m = 1; m <= 12; ++m)
{
for (auto d = 1; d <= last_day_of_month_common_year(m); ++d)
{
auto z = days_from_civil(2021, m, d);
auto [y1, m1, d1] = civil_from_days(z);
std::cout << y1 << '-' << m1 << '-' << d1 << '\n';
}
}
}
Using:
clang++ test.cpp -std=c++17 -I../date/include -Wall -fsanitize=undefined
And it ran with no errors or warnings. I'm concluding that there is no undefined behavior on this line.
const unsigned m = mp + (mp < 10 ? 3 : -9); // [1, 12]
This line is UB since -9 is converted to unsigned? Or am I wrong?