Mantis - Cafesterol
Erweiterte Problemanzeige
14 general schwerer Fehler immer 2008-06-26 19:21 2008-06-27 16:51
anonymous  
xclerc  
normal  
erledigt 1.0  
erledigt  
keine    
keine 1.0  
0000014: float array literals produce zero-length arrays
Array expressions like [| x |] or [| x ; x |], where x is a float variable,
produce a zero-length array.

Array expressions with other element types work as expected.
Array expressions with floating-point literals like [| 1.0 |] work as well.
$ cat arraybug.ml
let singleton_literal x = [| x |]
let singleton_array_make x = Array.make 1 x
let test singleton x = Printf.printf " %d" (Array.length (singleton x))
let () =
  test singleton_literal 1;
  test singleton_array_make 1;
  test singleton_literal 1.0;
  test singleton_array_make 1.0;
  print_newline ()

$ ocamljava -standalone -o arraybug.jar arraybug.ml
$ java -jar arraybug.jar
 1 1 0 1

$ ocamlopt -o arraybug.opt arraybug.ml
$ ./arraybug.opt
 1 1 1 1

$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

$ ocamljava -config
version (ocaml): 3.10.2
version (cafesterol): 1.0
standard_library: /usr/local/lib/ocaml
standard_runtime: /usr/local/bin/ocamlrun
ccomp_type: javac
architecture: Java
model: JVM 1.5+
ext_obj: .jo
ext_lib: .jar
default_executable_name: camlprog.jar
systhread_supported: true

$ ocamlopt -config
version: 3.10.2
standard_library_default: /usr/local/lib/ocaml
standard_library: /usr/local/lib/ocaml
standard_runtime: /usr/local/bin/ocamlrun
ccomp_type: cc
bytecomp_c_compiler: gcc -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
bytecomp_c_linker: gcc -Wl,-E
bytecomp_c_libraries: -lm -ldl -lcurses -lpthread
native_c_compiler: gcc -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
native_c_linker: gcc
native_c_libraries: -lm -ldl
native_partial_linker: ld -r
ranlib: ranlib
cc_profile: -pg
architecture: i386
model: default
system: linux_elf
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Unix
default_executable_name: a.out
systhread_supported: true
Problem-Historie
2008-06-26 19:21 anonymous Neues Problem
2008-06-27 16:51 xclerc Status neu => erledigt
2008-06-27 16:51 xclerc Behoben in Version => 1.0
2008-06-27 16:51 xclerc Lösung offen => erledigt
2008-06-27 16:51 xclerc Bearbeitung durch => xclerc
2008-06-27 16:51 xclerc Problemnotiz hinzugefügt: 0000010

Notiz
(0000010)
xclerc   
2008-06-27 16:51   
The same problem occurs when the provided source is compiled with "ocamlc",
and then run with "ocamlrun.jar".
Actually, the bug lies in the implementation of the "caml_make_array" primitive.
When the primitive was passed a "classical" block containing floats values, it tried
to use it as a "double array" block. It is indeed the only task of the primitive to
take a "classical" block corresponding to an array, and to return a "double array"
block if the elements are floats.

The bug is now fixed in the Darcs repository of the Cadmium project.