[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Damien Doligez <damien.doligez@i...> |
| Subject: | Re: [Caml-list] Converting variants with only constant constructors to integers |
Hi Kaustuv,
On 2010-06-08, at 20:22, Kaustuv Chaudhuri wrote:
>> Of course intify can cause a segmentation fault!
>>
>> # let arr = Array.of_list [intify 1.0; 0];;
>> Segmentation fault
>
> This may be splitting hairs, but the reason that fails is that
> Array.of_list's ad hoc polymorphism heuristic assumes that if the
> first element of the list is allocated, then all elements are
> allocated. Merely changing the order works.
Then again, good old addition has the same kind of problem with
intify.
$ ocaml
Objective Caml version 3.12.0
# external intify : 'a -> int = "%identity";;
external intify : 'a -> int = "%identity"
# let x = 1 + intify (1, 2);;
val x : int = 2147734445
# Gc.minor ();;
ocamlrun(11589) malloc: *** mmap(size=184834061894270976) failed (error code=12)
*** error: can't allocate region
-- Damien