From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 DE61CBC57 for ; Tue, 8 Jun 2010 20:22:29 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.53,385,1272837600"; d="scan'208";a="52693159" Received: from mail-pv0-f180.google.com ([74.125.83.180]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 08 Jun 2010 20:22:29 +0200 Received: by pvg7 with SMTP id 7so2030250pvg.39 for ; Tue, 08 Jun 2010 11:22:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.215.204 with SMTP id hf12mr3813310qcb.264.1276021346482; Tue, 08 Jun 2010 11:22:26 -0700 (PDT) Received: by 10.229.4.204 with HTTP; Tue, 8 Jun 2010 11:22:26 -0700 (PDT) In-Reply-To: References: <4C0D3557.1020200@gmail.com> <010d01cb0672$09f3eb90$1ddbc2b0$@romulus.metastack.com> <4C0D4C88.4070102@gmail.com> Date: Tue, 8 Jun 2010 20:22:26 +0200 Message-ID: Subject: Re: [Caml-list] Converting variants with only constant constructors to integers From: Kaustuv Chaudhuri To: Jacques Garrigue Cc: bluestorm , caml-list caml-list Content-Type: text/plain; charset=UTF-8 X-Spam: no; 0.00; variants:01 constructors:01 integers:01 polymorphism:01 abstr:01 abstr:01 1.0:98 1.0:98 wrote:01 caml-list:01 heuristic:02 allocated:02 allocated:02 garrigue:03 garrigue:03 On Tue, Jun 8, 2010 at 4:37 PM, Jacques Garrigue 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. # Array.of_list [Obj.repr 0 ; Obj.repr 1.0] ;; - : Obj.t array = [|; |] Which one of Obj.repr of Array.of_list to blame, if that's the right word, is not that relevant to any code a sane person might write. -- Kaustuv