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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id E753D7EE25 for ; Tue, 5 Nov 2013 10:53:02 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of nicolas@incubaid.com) identity=pra; client-ip=209.85.215.175; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas@incubaid.com"; x-sender="nicolas@incubaid.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of nicolas@incubaid.com) identity=mailfrom; client-ip=209.85.215.175; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas@incubaid.com"; x-sender="nicolas@incubaid.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ea0-f175.google.com) identity=helo; client-ip=209.85.215.175; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nicolas@incubaid.com"; x-sender="postmaster@mail-ea0-f175.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArACAKK+eFLRVdevlGdsb2JhbABahxq8MoEmFg4BAQEBBwsLCRIqgiUBAQUjVhALDgoCAiYCAjQBBQEcBhOIAQQBn1mMBJI6gSmMfYEzB4JrgUQDlCuKHIQHhVlBhFKBaA X-IPAS-Result: ArACAKK+eFLRVdevlGdsb2JhbABahxq8MoEmFg4BAQEBBwsLCRIqgiUBAQUjVhALDgoCAiYCAjQBBQEcBhOIAQQBn1mMBJI6gSmMfYEzB4JrgUQDlCuKHIQHhVlBhFKBaA X-IronPort-AV: E=Sophos;i="4.93,638,1378850400"; d="scan'208";a="40981467" Received: from mail-ea0-f175.google.com ([209.85.215.175]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Nov 2013 10:52:29 +0100 Received: by mail-ea0-f175.google.com with SMTP id l15so3253827eak.6 for ; Tue, 05 Nov 2013 01:53:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version:content-transfer-encoding; bh=u+p/fTcIfAfIKaZBN5tJdbROOFRKHrkL0YpNO/qFi98=; b=jnHA8oWbTU9iD9m6v8OLA+WSEbWa47cRjm/oylfn04ymYn9zILcBLBj/dTqUpYBh20 mn9y58Gfv1hT+m5YTnwSBheDIb5V0jXW9SZkv4Rvt6bYzRMoq3gVTHwP9NcdAiG8v3l4 Ic139Slq6nu9x9RPrYUDGEFVOYkSonvvCB4sxrs8EnanL0q0eBlm0vfyTkw2WW1XIREW u29gv24c7+DhBKbEcHoxdPCtTsxlIGg1Wh2EVea7z0Xfrs5mfCb6zVwz2+gfW77tUuxf PubS3xz9rLqD90GmNwklw83jb3k2bEbkimthspZ5yoAo+xrS1+wkpX4XDm/i8AMG1psd eehg== X-Gm-Message-State: ALoCoQk3zipTUCnO9vxZvhMLa9N1Qqa6PqqRAMmjkT8mhUd5CWqXNh2DF1H2fJkvgN489W7CJaNY X-Received: by 10.15.64.1 with SMTP id n1mr23411396eex.15.1383645181941; Tue, 05 Nov 2013 01:53:01 -0800 (PST) Received: from [192.168.123.153] (78-20-0-121.access.telenet.be. [78.20.0.121]) by mx.google.com with ESMTPSA id s3sm58014510eeo.3.2013.11.05.01.53.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Nov 2013 01:53:01 -0800 (PST) Message-ID: <1383645204.20247.1.camel@tau.nicolast.be> From: Nicolas Trangez To: Ivan Gotovchits Cc: caml-list@inria.fr Date: Tue, 05 Nov 2013 10:53:24 +0100 In-Reply-To: <87a9hjmrk2.fsf@golf.niidar.ru> References: <1383605662.24373.7.camel@tau.nicolast.be> <87a9hjmrk2.fsf@golf.niidar.ru> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5 (3.8.5-2.fc19) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Bug in caml_string_get16? 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