www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - ieeeFlags do not work properly

reply Torben Hagerup <hagerup informatik.uni-augsburg.de> writes:
Run under D version 2.037, the program below runs through without raising any
assert exceptions. This shows an erratic behavior with respect to ieeeFlags
that is hardly intended. Other ieeeFlags also work (or, rather, do not work) in
unexpected ways.

--------------------

import std.math;

void main() {
// The execution leads to no assert errors
 real a,b=3.5;
 resetIeeeFlags();
 assert(!ieeeFlags.divByZero); // so far no zero division
 a=3.5/0.0L; // but now ...
 assert(a==real.infinity); // yes, exactly
 assert(!ieeeFlags.divByZero); // perhaps not, after all
 b/=0.0L; // once more, the same, really
 assert(b==real.infinity); // yes, the same
 assert(ieeeFlags.divByZero); // oops, not the same after all?
}
Jan 07 2010
next sibling parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
Torben Hagerup wrote:
 Run under D version 2.037, the program below runs through without raising any
assert exceptions. This shows an erratic behavior with respect to ieeeFlags
that is hardly intended. Other ieeeFlags also work (or, rather, do not work) in
unexpected ways.
 
 --------------------
 
 import std.math;
 
 void main() {
 // The execution leads to no assert errors
  real a,b=3.5;
  resetIeeeFlags();
  assert(!ieeeFlags.divByZero); // so far no zero division
  a=3.5/0.0L; // but now ...
  assert(a==real.infinity); // yes, exactly
  assert(!ieeeFlags.divByZero); // perhaps not, after all
  b/=0.0L; // once more, the same, really
  assert(b==real.infinity); // yes, the same
  assert(ieeeFlags.divByZero); // oops, not the same after all?
 }
Hi! Please report bugs in Bugzilla: http://d.puremagic.com/issues/index.cgi This newsgroup is just a feed from Bugzilla. -Lars
Jan 07 2010
prev sibling parent Don <nospam nospam.com> writes:
Torben Hagerup wrote:
 Run under D version 2.037, the program below runs through without raising any
assert exceptions. This shows an erratic behavior with respect to ieeeFlags
that is hardly intended. Other ieeeFlags also work (or, rather, do not work) in
unexpected ways.
 
 --------------------
This isn't a bug.
 import std.math;
 
 void main() {
 // The execution leads to no assert errors
  real a,b=3.5;
  resetIeeeFlags();
  assert(!ieeeFlags.divByZero); // so far no zero division
  a=3.5/0.0L; // but now ...
This occurred at compile time. At runtime, this became: a = real.infinity;
  assert(a==real.infinity); // yes, exactly
  assert(!ieeeFlags.divByZero); // perhaps not, after all
  b/=0.0L; // once more, the same, really
It's not the same. This is a runtime division by zero.
  assert(b==real.infinity); // yes, the same
  assert(ieeeFlags.divByZero); // oops, not the same after all?
 }
Jan 07 2010