[MLton] possible x86 codegen bug with 64-bit ints
Stephen Weeks
MLton@mlton.org
Fri, 21 Jan 2005 22:35:00 -0800
Scott Cruzen reported (a variant of) this bug on #sml. MLton 20041109
generates incorrect code for the following program.
----------------------------------------------------------------------
val args = CommandLine.arguments()
val _ =
let
val stream = TextIO.getInstream (TextIO.openIn (hd args))
val (str, stream) = TextIO.StreamIO.inputN (stream, 100)
val pos = TextIO.StreamIO.filePosIn stream
val _ = print (Position.toString pos)
val _ = print "\n"
val _ = TextIO.StreamIO.inputLine stream
val _ = print (Position.toString pos)
val _ = print "\n"
in
()
end
----------------------------------------------------------------------
When run with a text file for its first argument, it should print
100
100
However, it instead prints
100
429496729700
This is a very weird bug, since, as you can see in the code, "pos"
is an immutable value (a 64-bit integer). The problem may be an x86
codegen bug, since the program works fine when compiled -codegen c or
-codegen bytecode. Since the 64-bit stuff is pretty new, I suspect
that is the problem area.
Incidentally, when I tried to compile this program with the CVS head
MLton and -codegen bytecode, I got the following error:
missing opcode: Int32_storeStackOffset
I think this may have something to do with the recent changes (which I
haven't yet had time to investigate) to type synonym replacement in
the front end.