The ``foreign import'' bug for Float types is still present in ghc-4.08.
(I think Floats are being silently promoted to Doubles, which as far
as I can tell is wrong - this is a difference between K&R1 and ANSI C.)
Regards,
Malcolm
----Main.hs----
module Main where
foreign import floatToInt :: Float -> Int
main = let f :: [Float]
f = [1.0, 1.2, 1.4, 1.6, 1.8, 2.0]
print f
print (map floatToInt f)
----floatToInt.c----
int floatToInt (float fl) {
union {
float f;
int i;
} tmp;
tmp.f = fl;
return tmp.i;
}
----expected output (produced by nhc98)----
[1.00000000,1.20000005,1.39999998,1.60000002,1.79999995,2.00000000]
[1065353216,1067030938,1068708659,1070386381,1072064102,1073741824]
----actual output (produced by ghc)----
[1.0,1.2,1.4,1.6,1.8,2.0]
[0,1073741824,1610612736,-1610612736,-1073741824,0]
----end----