www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11352] New: core.time does not check for overflow when converting integrals to a Duration

http://d.puremagic.com/issues/show_bug.cgi?id=11352

           Summary: core.time does not check for overflow when converting
                    integrals to a Duration
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-25
09:26:32 PDT ---
-----
import std.stdio;
import core.time;

void main()
{
    writeln((ulong.max / 120).seconds);
    writeln((ulong.max / 60).seconds);
}
-----

1016685 weeks, 4 days, 9 hours, 52 minutes, 3 secs, 518 ms, 387 μs, and 2
hnsecs
-1016685 weeks, -4 days, -9 hours, -52 minutes, -3 secs, -918 ms, -387 μs, and
-2 hnsecs

Duration uses a `long` internally, so it should likely try to do some checks
before attempting to initialize itself to a ulong.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013