www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15221] New: Duration should treat division by 0 as a logic

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

          Issue ID: 15221
           Summary: Duration should treat division by 0 as a logic error
                    rather than throwing an exception
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: issues.dlang jmdavisProg.com

Duration should never have checked for division by 0 and thrown a TimeException
when it occurred. The OS/hardware already checks for that, and it should be
considered a logic error. Checking for it and possibly throwing just slows the
code down and makes it so that it can't be  nogc. 

This is technically a breaking change, but it will only break code which
doesn't bother to avoid dividing by 0 and then catches TimeException when it
occurs, and such code is likely extremely rare, if it exists at all. Given the
fact that the odds of actually breaking code are extremely low and that this
allows us to make Duration fully  nogc except for toString, I think that it's
worth the risk.

--
Oct 18 2015