October 12, 2017 [Issue 11352] core.time does not check for overflow when converting integrals to a Duration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=11352 Jonathan M Davis <issues.dlang@jmdavisProg.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |issues.dlang@jmdavisProg.co | |m Resolution|--- |WONTFIX --- Comment #1 from Jonathan M Davis <issues.dlang@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. -- |
Copyright © 1999-2021 by the D Language Foundation