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 0EB777EE25 for ; Mon, 4 Nov 2013 23:54:18 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas@incubaid.com) identity=pra; client-ip=209.85.215.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas@incubaid.com"; x-sender="nicolas@incubaid.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas@incubaid.com) identity=mailfrom; client-ip=209.85.215.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas@incubaid.com"; x-sender="nicolas@incubaid.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ea0-f181.google.com) identity=helo; client-ip=209.85.215.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas@incubaid.com"; x-sender="postmaster@mail-ea0-f181.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj4DAFUleFLRVde1lGdsb2JhbABZhxq9YBYOAQEBAQcLCwkSKoJPBIEHAiYCNgEFAYg2BAGce4MEjASSOIEpjkyCVYFDA55HhAeFWUGEUg X-IPAS-Result: Aj4DAFUleFLRVde1lGdsb2JhbABZhxq9YBYOAQEBAQcLCwkSKoJPBIEHAiYCNgEFAYg2BAGce4MEjASSOIEpjkyCVYFDA55HhAeFWUGEUg X-IronPort-AV: E=Sophos;i="4.93,635,1378850400"; d="scan'208";a="33732274" Received: from mail-ea0-f181.google.com ([209.85.215.181]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 04 Nov 2013 23:54:04 +0100 Received: by mail-ea0-f181.google.com with SMTP id d10so3787276eaj.40 for ; Mon, 04 Nov 2013 14:54:03 -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:date:content-type :mime-version:content-transfer-encoding; bh=BVAY5iQcT9LhxH5k2LAWkMQdt8ZQ4mY0qoJW97l+f2A=; b=OdJqm0PAbONigAKEcDpLxUFZ3YCRA6axyaty0e2u4x/uvgE6ghkRMa/IVVUIMKdG0U 1Xwbl3wlchYojN6waa6V4djev8yYbkUHQfm8nam2TKGN8Sc9lLMSMt9LBY7Pc95Kjh8J LUB0Wms6pHizBv5GwP1NIA5hmze8GHgghbQJDWmhA5g8OAK3gpKkuVdaaelBxX8hPpj7 bpt5PaotAIzpdIOmn6I/Pz8sBjwzzp+ceU49l0MDximBRkDplR2tEoRQTSoA8iTMR3uc LjIbjHtaDs/zdFGmPdEc9uhIHFU2wmO/AjiWzI9q3TsBN2QCywshFElFXJ0Ky/egMBue s+qA== X-Gm-Message-State: ALoCoQlq+LFNWqFdoBEQMJEWlgjk4LUwwGCdSDEwDCEPY38alqRRouT076pYgalidSh4nvcvMTBA X-Received: by 10.14.241.141 with SMTP id g13mr7277786eer.75.1383605643633; Mon, 04 Nov 2013 14:54:03 -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 8sm20884683eem.15.2013.11.04.14.54.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 04 Nov 2013 14:54:02 -0800 (PST) Message-ID: <1383605662.24373.7.camel@tau.nicolast.be> From: Nicolas Trangez To: caml-list@inria.fr Date: Mon, 04 Nov 2013 23:54:22 +0100 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: [Caml-list] Bug in caml_string_get16? All, I was playing around with *ocplib-endian* a couple of days ago (to access the `%caml_string_getN` primops), and found something strange going on (which I think might be a bug). What would you expect to be the output of this code? ```ocaml external get_16 : string -> int -> int = "%caml_string_get16" let main () = let () = try let i = get_16 "1" 0 in Printf.printf "Uh-oh 1: %d\n" i with exn -> Printf.printf "Got %s :-)\n" (Printexc.to_string exn) in try let i = get_16 "" 0 in Printf.printf "Uh-oh 2: %d\n" i with exn -> Printf.printf "Got %s :-)\n" (Printexc.to_string exn) ;; main () ``` Here's what it does on my system: ``` $ ocamlopt -version 4.01.0 $ ocamlbuild -use-ocamlfind parse.native Finished, 4 targets (0 cached) in 00:00:00. $ ./parse.native Got Invalid_argument("index out of bounds") :-) Uh-oh 2: 0 ``` I think there's something fishy going on here... I didn't test, but I guess other related functions (32/64 bit & unsafe variants) could be affected as well. Nicolas