You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 2019 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Aleksey Nogin
Version: 3.07+12 (2004-01-03) from CVS
OS: Fedora Core Development
Submission from: charter-242-037.caltech.edu (131.215.242.37)
Summary: It seems that on AMD64 the input_binary_int function is capable of
reading an integer that's different from what was passed to output_binary_int.
One would expect that teh following code:
let f = open_out_bin "/tmp/foo";;
output_binary_int f i;;
close_out f;;
let f = open_in_bin "/tmp/foo";;
let i' = input_binary_int f;;
close_in f;;
i' = i;;
Would output "true" for any int i. However this is not the case on AMD64:
matrix41:~> ocaml
Objective Caml version 3.07+12 (2004-01-03)
let i = 0x89ac12bd;;
val i : int = 2309755581
let f = open_out_bin "/tmp/foo";;
val f : out_channel =
output_binary_int f i;;
: unit = ()
close_out f;;
: unit = ()
let f = open_in_bin "/tmp/foo";;
val f : in_channel =
let i' = input_binary_int f;;
val i' : int = -1985211715
close_in f;;
: unit = ()
i' == i;;
: bool = false
i' = i;;
: bool = false
while the same thing works "correctly" on a 32-bit machine - at least with
3.06:
Objective Caml version 3.06
let i = 0x89ac12bd;;
val i : int = 162271933
let f = open_out_bin "/tmp/foo";;
val f : out_channel =
output_binary_int f i;;
: unit = ()
close_out f;;
: unit = ()
let f = open_in_bin "/tmp/foo";;
val f : in_channel =
let i' = input_binary_int f;;
val i' : int = 162271933
close_in f;;
: unit = ()
i' = i;;
: bool = true
On another 32-bit machine:
Objective Caml version 3.07+7 (2003-12-17)
let i = 0x89ac12bd;;
Integer literal exceeds the range of representable integers of type int
Which is IMO pretty reasonable.
The text was updated successfully, but these errors were encountered:
Original bug ID: 2019
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Aleksey Nogin
Version: 3.07+12 (2004-01-03) from CVS
OS: Fedora Core Development
Submission from: charter-242-037.caltech.edu (131.215.242.37)
Summary: It seems that on AMD64 the input_binary_int function is capable of
reading an integer that's different from what was passed to output_binary_int.
One would expect that teh following code:
let f = open_out_bin "/tmp/foo";;
output_binary_int f i;;
close_out f;;
let f = open_in_bin "/tmp/foo";;
let i' = input_binary_int f;;
close_in f;;
i' = i;;
Would output "true" for any int i. However this is not the case on AMD64:
matrix41:~> ocaml
Objective Caml version 3.07+12 (2004-01-03)
let i = 0x89ac12bd;;
val i : int = 2309755581
let f = open_out_bin "/tmp/foo";;
val f : out_channel =
output_binary_int f i;;
close_out f;;
let f = open_in_bin "/tmp/foo";;
val f : in_channel =
let i' = input_binary_int f;;
val i' : int = -1985211715
close_in f;;
i' == i;;
i' = i;;
while the same thing works "correctly" on a 32-bit machine - at least with
3.06:
let i = 0x89ac12bd;;
val i : int = 162271933
let f = open_out_bin "/tmp/foo";;
val f : out_channel =
output_binary_int f i;;
close_out f;;
let f = open_in_bin "/tmp/foo";;
val f : in_channel =
let i' = input_binary_int f;;
val i' : int = 162271933
close_in f;;
i' = i;;
On another 32-bit machine:
let i = 0x89ac12bd;;
Integer literal exceeds the range of representable integers of type int
Which is IMO pretty reasonable.
The text was updated successfully, but these errors were encountered: