[Issue 18552] New: std.datetime.date.Date strips year int argument to short

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 4 00:37:27 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18552

          Issue ID: 18552
           Summary: std.datetime.date.Date strips year int argument to
                    short
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: feklushkin.denis at gmail.com

std.datetime.date.Date accepts int year as argument but silently strips it to
short:

    this(int year, int month, int day) @safe pure
    {
        enforceValid!"months"(cast(Month) month);
        enforceValid!"days"(year, cast(Month) month, day);

        _year  = cast(short) year;
        _month = cast(Month) month;
        _day   = cast(ubyte) day;
    }

It is need to add bounds check or change argument type.

--


More information about the Digitalmars-d-bugs mailing list