From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 3784ABBAF for ; Mon, 23 Aug 2010 16:36:20 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.56,257,1280700000"; d="scan'208";a="57693821" Received: from macadam.inria.fr ([128.93.8.130]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 23 Aug 2010 16:36:20 +0200 Subject: Re: [Caml-list] Converting variants with only constant constructors to integers Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Damien Doligez In-Reply-To: Date: Mon, 23 Aug 2010 16:36:19 +0200 Cc: caml-list caml-list Content-Transfer-Encoding: quoted-printable Message-Id: References: <4C0D3557.1020200@gmail.com> <010d01cb0672$09f3eb90$1ddbc2b0$@romulus.metastack.com> <4C0D4C88.4070102@gmail.com> To: Kaustuv Chaudhuri X-Mailer: Apple Mail (2.1081) X-Spam: no; 0.00; variants:01 constructors:01 integers:01 damien:01 damien:01 polymorphism:01 ocaml:01 val:01 ocamlrun:01 malloc:01 1.0:98 doligez:01 doligez:01 wrote:01 caml-list:01 Hi Kaustuv, On 2010-06-08, at 20:22, Kaustuv Chaudhuri wrote: >> Of course intify can cause a segmentation fault! >>=20 >> # let arr =3D Array.of_list [intify 1.0; 0];; >> Segmentation fault >=20 > 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 =3D "%identity";; external intify : 'a -> int =3D "%identity" # let x =3D 1 + intify (1, 2);; val x : int =3D 2147734445 # Gc.minor ();; =20 ocamlrun(11589) malloc: *** mmap(size=3D184834061894270976) failed = (error code=3D12) *** error: can't allocate region -- Damien