Bug in Float.valueOf(String)

Alexandre Oliva oliva at dcc.unicamp.br
Mon Jan 25 12:47:28 PST 1999


On Jan 25, 1999, Archie Cobbs <archie at whistle.com> wrote:

> Maxim Kizub writes:

>> /* Floats are passed as doubles in C!!!!!
>> obj = (struct
>> Hjava_lang_Float*)execute_java_constructor("java.lang.Float", 0, "(F)V",
>> (float)java_lang_Double_valueOf0(str));

> I don't understand.. what's the problem? Are you just complaining about
> the loss of precision, or something worse?

It's much worse, and it's a problem of Kaffe I have reported to Tim
Wilkinson and documented in release 1.1 (or maybe 1.2) of Guaraná.  In
C, floats are promoted to doubles in ellipsis arguments, but Kaffe JIT
generates code to read a float from the stack, not a double.
Therefore, the constructor ends up picking the wrong value out of the
stack.  The problem also affects return values, if my memory serves.

-- 
Alexandre Oliva  http://www.dcc.unicamp.br/~oliva  aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Universidade Estadual de Campinas, SP, Brasil



More information about the kaffe mailing list