From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 1A661BB84 for ; Tue, 13 Jan 2009 10:37:35 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.37,258,1231110000"; d="scan'208";a="33658174" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 13 Jan 2009 10:37:34 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id n0D9bYYf015222 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 13 Jan 2009 10:37:34 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au0BAA3wa0lN6B+lmWdsb2JhbACBbJBjgUcBAQEBAQgLCgcRvEqFbw X-IronPort-AV: E=Sophos;i="4.37,258,1231110000"; d="scan'208";a="19517464" Received: from fe02x03-cgp.akado.ru (HELO akado.ru) ([77.232.31.165]) by mail2-smtp-roc.national.inria.fr with ESMTP; 13 Jan 2009 10:37:33 +0100 Received: from [10.0.66.9] ([10.0.66.9] verified) by fe02-cgp.akado.ru (CommuniGate Pro SMTP 5.1.16) with ESMTPS id 40960145; Tue, 13 Jan 2009 12:37:32 +0300 Date: Tue, 13 Jan 2009 12:37:36 +0300 (MSK) From: malc X-X-Sender: malc@linmac.oyster.ru To: Daniel de Rauglaudre Cc: caml-list@inria.fr Subject: Re: [Caml-list] caml_alloc + 64 bits - caml_alloc.h In-Reply-To: <20090113045116.GA646@yquem.inria.fr> Message-ID: References: <20090113045116.GA646@yquem.inria.fr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 496C60DE.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; malc:01 alloc:01 alloc:01 rauglaudre:01 compilation:01 stub:01 ocaml:01 ocaml:01 morality:98 wrote:01 caml-list:01 int:01 caml:02 caml:02 segmentation:03 On Tue, 13 Jan 2009, Daniel de Rauglaudre wrote: > Hi everybody, > > Possibly useful information. Is it already known? > > When using calls to "caml_alloc" in a 64 bits architecture without > having included "caml/alloc.h", it raises "Segmentation fault" at > execution time. > > Notice that I got no warning at compilation time for using caml_alloc > without a definition stub. > > In 32 bits architecture, I never had any problem with that. caml_alloc returns value which is typedefed to intnat which in turn is long which is 64bit on LP64 architectures (for all practical intents and purposes anything that is not Win64), when prototype for caml_alloc is missing it is assumed to be `int caml_alloc();' assigning the return value of this call to value will sign extend it with devastating results (upper 32bit lost forever) > Morality: > Don't forget to #include "caml/alloc.h" in your C programs > if you alloc OCaml things! Moraility is to follow relevant standard actually.. P.S. This whole value->intnat->long makes me wonder how OCaml is ever supposed to work on LLP64... -- mailto:av1474@comtv.ru