[Issue 11352] core.time does not check for overflow when converting integrals to a Duration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 12 03:09:07 UTC 2017


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m
         Resolution|---                         |WONTFIX

--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
This is just life with integral types - especially when they're the same size
but have different signed-ness. If you want to convert to long from ulong and
have it check for overflow, then use std.conv.to!long on the number before
constructing a Duration from it. It's quite clear from the signature of dur and
its aliases that it takes a long, not a ulong, and always checking for overflow
would add overhead for something that happens very rarely. std.conv.to already
makes it easy for the programmer to check if they care.

--


More information about the Digitalmars-d-bugs mailing list