[Issue 6303] New: Order of float declaration changes NaN throwing behavior

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 12 17:28:42 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6303

           Summary: Order of float declaration changes NaN throwing
                    behavior
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-07-12 17:23:32 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list