Real.maxFinite bug

Stephen Weeks MLton@sourcelight.com
Wed, 3 Oct 2001 15:20:21 -0700


> Now, it's trivial to do the following in real.c:
> 
> long long const maxPos = 0xF..F;
> 
> Then do, in the Real structure of primitives.sml,
> 	val maxPos = _ffi "Real_maxPos": real;
> 
> And then in the Real structure of real.sml
> 	val maxPos = Primitive.maxPos
> 
> (I think the second assignment will allow the value to be fetched once as
> a global during initGlobals, rather than each time.)

Nope.  The second binding will be simplified away.  The first binding means that
Real_maxPos will be looked at once, at program startup, but not during
initGlobals, because FFIs are never moved.  To see this, look at the dot for a
simple program like

val foo = _ffi "foo": real;

val _ =
   if Real.== (foo, 13.0)
      then ()
   else raise Fail "bug"

My point about maxPos being stored in closure records still applies with this
approach.