[clean-list] Is freadi broken in 64-bit Clean?

John van Groningen johnvg at cs.ru.nl
Mon Sep 14 15:39:11 MEST 2009


Maks Verver wrote:
>..
>Of course this is very strange: I expected Case #1 to print 123. As you can see, reading does succeed, and the following values are read correctly. Now, 140733193388155 is 0x7fff0000007b and 0x7b is indeed 123, so it appears that freadi actually only reads a 32-bit integer and leaves garbage in the upper 32 bits of the resulting integer.

On the 64 bit linux version only the least significand 32 bits are correct.
This happens because the C function that is used to implement freadi uses
int* instead of long*. I have fixed this in the source code.

>Is this a known problem? Any suggestions on how to fix this or work around it?

If 32 bit numbers are sufficient, shift the result 32 bits to the left and
then 32 bits to the right, or if it is unsigned, 'bitand' with 0xffffffff.

If you need more bits, you can implement freadi using freadc.

Kind regards,

John van Groningen


More information about the clean-list mailing list