# [libc++] Avoid UB in year_month_day_last::day() for incorrect monthsClosedPublicActions

Authored by ldionne on Jun 9 2020, 9:35 AM.

# Details

Reviewers
 howard.hinnant
Group Reviewers
 Restricted Project
Commits
rG1f48f8f6e289: [libc++] Avoid UB in year_month_day_last::day() for incorrect months
Summary

This effectively implements the resolution of LWG3231, which mandates
that calling year_month_day_last::day() on an invalid year_month_day_last
is unspecified behavior. Before this change, it was undefined behavior.

# Diff Detail

### Event Timeline

ldionne created this revision.Jun 9 2020, 9:35 AM
Herald added a project: Restricted Project. Jun 9 2020, 9:35 AM
Herald added a reviewer: Restricted Project.
Herald added subscribers: libcxx-commits, dexonsmith, jkorous.

Note that a test was added in cb347a1106a76e248a6c0d78451a018b20662c03, and in fact this UB did trigger a failure in the ASAN bot due to the added test.

So basically this commit fixes the LWG issue, and the tests for it have been added in cb347a1106a76e248a6c0d78451a018b20662c03. Sorry if that's confusing, everything should have been added in this commit, but I didn't fully understand the issue yet and I didn't know this commit was going to be necessary.

ldionne accepted this revision as: Restricted Project.Jun 9 2020, 10:43 AM
This revision is now accepted and ready to land.Jun 9 2020, 10:43 AM
This revision was automatically updated to reflect the committed changes.