Bug 13743 – floating point inconsistent division by zero

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-11-17T11:15:00Z
Last change time
2017-06-26T13:48:07Z
Keywords
wrong-code
Assigned to
nobody
Creator
public
See also
https://issues.dlang.org/show_bug.cgi?id=5908

Comments

Comment #0 by public — 2014-11-17T11:15:57Z
``` void main() { real x = 1; real y = x / 0; assert(y is real.infinity); } ``` This passes when compiled without optimizations and fails when compiled with -O. When optimizations are enabled y is evaluated as NaN (probaby because of const-folding?) I don't know if this is bug or feature and if it should be fixed / changed at all but creating bugzilla issue just so that it won't be as much of surprise to others :)
Comment #1 by clugdbug — 2014-11-17T11:25:01Z
This seems related to bug 5908. The fix there did not fix all of the issues with division by zero. This is not a regression, though. The bug applied also to DMD 2.063. x/0 is NaN only if x is 0.0 or infinity. Otherwise the result should be +-real.infinity.
Comment #2 by yebblies — 2014-11-17T12:02:14Z
I can't reproduce with master on win32. I assume this is with master?
Comment #3 by clugdbug — 2014-11-17T12:11:31Z
It is happening on linux64. Would be interesting if it turned out to be Linux-only, or 64bit only.
Comment #4 by public — 2014-11-18T02:57:03Z
DMD git master, linux. Happens with both -m64 and -m32
Comment #5 by dlang-bugzilla — 2017-06-26T13:48:07Z
Fixed in https://github.com/dlang/dmd/pull/3810, so I assume this is a duplicate of 5908. *** This issue has been marked as a duplicate of issue 5908 ***