val x = valOf (Word64.fromString "1234567890abcdef")<br>val y = MLton.Word64.ror (x, 0w32)<br>val z = Word64.orb (Word64.<< (x, 0w32), Word64.>> (x, 0w32))<br><br>val () = print (Word64.toString y ^ "\n")<br>
val () = print (Word64.toString z ^ "\n")<br><br>Output:<br>1234567890ABCDEF<br>90ABCDEF12345678<br><br>Expected output:<br>90ABCDEF12345678<br>90ABCDEF12345678<br><br>I've checked that this bug is NOT from gcc by compiling the following:<br>
#include <stdint.h><br>#include <stdio.h><br><br>uint64_t Word64_ror(uint64_t w1, uint32_t w2);<br><br>int main () {<br> uint64_t x = Word64_ror(0x1234567890ABCDEFUL, 32);<br> printf ("%llX\n", x);<br>
return 0;<br>}<br>gcc -Wall -O2 bug.c /usr/lib/mlton/self/libmlton.a -o bug<br><br>Output:<br>90ABCDEF12345678<br><br>The number 0w32 strikes me as a case that someone probably optimized incorrectly.<br><br>