Bug 6303 – Order of float declaration changes NaN throwing behavior

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-07-12T17:23:00Z
Last change time
2013-07-26T07:47:40Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-07-12T17:23:32Z
import std.math; void main() { float foo; FloatingPointControl fpc; fpc.enableExceptions(FloatingPointControl.allExceptions); //~ float foo; auto x = foo / 0; } This won't throw unless you replace the first foo declaration with the second one. This only happens with NaNs. If you initialize the float and do an invalid operation then it throws: import std.math; void main() { float foo = 0.0f; // initialize it first FloatingPointControl fpc; fpc.enableExceptions(FloatingPointControl.allExceptions); auto x = foo / 0; // throws, as it should } So this odd behavior only happens with NaNs.
Comment #1 by clugdbug — 2013-07-26T07:47:40Z
This is a symptom of bug 9813. *** This issue has been marked as a duplicate of issue 9813 ***