From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 15F587EE25 for ; Tue, 5 Nov 2013 11:50:33 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.214.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.214.54 as permitted sender) identity=mailfrom; client-ip=209.85.214.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-bk0-f54.google.com) identity=helo; client-ip=209.85.214.54; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-bk0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArICAELMeFLRVdY2lGdsb2JhbABagz9TrFmSYYEfCBYOAQEBAQcLCwkSKoIlAQEFJxkBGxILAQMMBgULDQ0hIgERAQUBChIGExKHXAEDDw2fYYxXgwmEHgoZJwMKZIkBAQUMjhQGgTMHhC8DlCuDX4EviRWFWRgphFI7gS0IFw X-IPAS-Result: ArICAELMeFLRVdY2lGdsb2JhbABagz9TrFmSYYEfCBYOAQEBAQcLCwkSKoIlAQEFJxkBGxILAQMMBgULDQ0hIgERAQUBChIGExKHXAEDDw2fYYxXgwmEHgoZJwMKZIkBAQUMjhQGgTMHhC8DlCuDX4EviRWFWRgphFI7gS0IFw X-IronPort-AV: E=Sophos;i="4.93,639,1378850400"; d="scan'208";a="33807609" Received: from mail-bk0-f54.google.com ([209.85.214.54]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Nov 2013 11:50:32 +0100 Received: by mail-bk0-f54.google.com with SMTP id 6so2808420bkj.41 for ; Tue, 05 Nov 2013 02:50:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=mCtHeEOFErMhZZajRqXpEPz0i+evsHMYphbPpjaPX4M=; b=X0SaUdOB5WMAmT1tgfEO4PQtx3TndHSGlQpMFm5G5AUKFxKlZhd8PegXbxPfVTTtzl QPXFUvMkMBl4SF2n7QqX1dFYu0IN1HMfp7anK4egAze1X+wHUij+mGeFpziMJEeQECre vQpjuv45B4zOQi63Aqj9o3xryPBdRYF3TX00q49PJgnNMPBL22FRZ2j4mqEKz9Q8TW/J ExDkezE50PpRjLJEO1iXA+Hw85x+Bf0rJeP6w3Ke7hoBMQgu/so8U8OGYBtCKjrpMDU6 V6aSQMyisC1DWpj7qFZB+Z28vEii88eY5tTVJXUjHestBOddQ31n+bJumsLFXFpgCPZZ ZVeA== X-Received: by 10.204.107.140 with SMTP id b12mr723898bkp.58.1383648631739; Tue, 05 Nov 2013 02:50:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.122.72 with HTTP; Tue, 5 Nov 2013 02:49:51 -0800 (PST) In-Reply-To: <1383645204.20247.1.camel@tau.nicolast.be> References: <1383605662.24373.7.camel@tau.nicolast.be> <87a9hjmrk2.fsf@golf.niidar.ru> <1383645204.20247.1.camel@tau.nicolast.be> From: Gabriel Scherer Date: Tue, 5 Nov 2013 11:49:51 +0100 Message-ID: To: Nicolas Trangez Cc: Ivan Gotovchits , caml users Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Bug in caml_string_get16? Despite the somewhat unclear reporting (I didn't read the first mail carefully enough to understand the problem), this is in fact a report for a very serious bug. I have a fix in the works that should end upstream quickly. OCaml version 4.01.0 # external set64 : string -> int -> int -> unit = "caml_string_set64";; external set64 : string -> int -> int -> unit = "caml_string_set64" # set64 "0" 1 42;; zsh: segmentation fault On Tue, Nov 5, 2013 at 10:53 AM, Nicolas Trangez wrote: > On Tue, 2013-11-05 at 07:54 +0400, Ivan Gotovchits wrote: >> Nicolas Trangez writes: >> >> > What would you expect to be the output of this code? >> >> It should fail :) >> >> In a string literal any symbol that you can type with your keyboard is >> stored in a special encoding called ASCII. With "1" you have just >> created a string containig a single byte with a value 49. So, first off >> all, your string is too short, because it has length of 1, when int16 >> obviously needs two bytes of storage space. If you really interested, >> binary 1 will be represented in a memory of a little endian computer >> like this: "\x01\x00". The special escape symbol "\" allows us to type >> untypable. The the code >> >> open EndianString >> let d = LittleEndian.get_int16 "\x01\x00" 0 >> >> will yield: >> >> val d : int = 1 >> >> By the way, if we try your string (with a more correct invocation): >> >> open EndianString >> let d = LittleEndian.get_int8 "1" 0 >> >> we will got: >> >> val d : int = 49 >> >> Futher reading: >> >> 1. man ascii >> 2. wikipedia article on endianess > > Oh, don't be mistaken. The question was rhetorical, in order to report a > bug (or get told it's not a bug at all) & provide a test-case :-) > I'm well aware of all of the above ;-) > > Thanks! > > Nicolas > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs