This reverts commit
0c148430cf61, which added an assertion in day().
The Standard doesn't allow day() to crash -- instead it says that the
result is unspecified.
Differential Revision: https://reviews.llvm.org/D70346
*/
#include <__config>
-#include <__debug>
#include <ctime>
#include <type_traits>
#include <ratio>
chrono::day(31), chrono::day(31), chrono::day(30),
chrono::day(31), chrono::day(30), chrono::day(31)
};
- _LIBCPP_ASSERT(ok(), "year_month_day_last::day(): year_month_day_last is invalid");
return month() != February || !__y.is_leap() ?
__d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
}
// __debug_less checks that a comparator actually provides a strict-weak ordering.
-#include <chrono> // Include before defining _LIBCPP_ASSERT: cannot throw in a function marked noexcept.
-
struct DebugException {};
-#ifdef _LIBCPP_ASSERT
-#undef _LIBCPP_ASSERT
-#endif
#define _LIBCPP_DEBUG 0
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : throw ::DebugException())
int main(int, char**)
{
+ using day = std::chrono::day;
using month = std::chrono::month;
using year_month = std::chrono::year_month;
using year = std::chrono::year;
}
}
- return 0;
+ // the result of year_month_day_last::day() is unspecified when !ok(),
+ // but it shouldn't crash.
+ {
+ year_month_day_last ymdl = year{2020}/month{13}/last;
+ assert(!ymdl.ok());
+ day d = ymdl.day(); (void)d; // doesn't crash
+ }
+
+ return 0;
}