Subject: Re: [boost] [chrono/date] date conversion and arithmetic with unvalidated dates
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2013-05-06 09:22:21


On May 6, 2013, at 6:30 AM, "Vicente J. Botet Escriba" <vicente.botet_at_[hidden]> wrote:

> Hi,
>
> Note that N3344 suggest only day arithmetic for a day representation (which is always valid) and suggest only only a date representation.
>
> Could we apply arithmetic operations on a unvalidated date (without striving on UB)?
> e.g. day arithmetic on a ymd_date
>
> ymd_date d1(year(2013), may, day(66));
> ymd_date d2 = d1 + day(1);
>
> If defined, which must be the value of d2?
>
> Could we convert a date representation to another one if the source date is unvalidated (without striving on UB)? e.g. ymd_date -> days_date
>
> ymd_date d1(year(2013), may, day(66));
> days_date d2 = d1;
>
> If defined, which must be the value of d2?

My understanding is that all of these operations (if unchecked at ymd_date construction time) are simply undefined behavior. This is what N3344 seems to be asking for.

Howard