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 509237FA5C for ; Fri, 13 May 2016 15:56:35 +0200 (CEST) IronPort-PHdr: 9a23:wmequxJiFEWhEQEY4tmcpTZWNBhigK39O0sv0rFitYgVIv/xwZ3uMQTl6Ol3ixeRBMOAu6MC0bOd7f2ocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC3oLtjqvsptX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD89pozcNLUL37cqIkVvQYSW1+ayFmrPHs4CHCQBGV6zM3UmwTmBNSH0CR9BD3RI389CD6v+930TOGFcr9RLUwQS6lqaxsTUmswG08MDM27HvQkog4qaNQoBuso1Y3l4vVa4GcOf44ZaTQcs8AQnJpX8BNWigHCYS5Oc9HReEIOOIdq4jmu3MPqwG/DE+iHqmnnjRBg3uz2awhz8wgFxvH1UouBYRdnm7TqYDcMK4TV6ib1qjTxjWLO/pS0Db7robScwsqodmIUKJxf8uXwk4qQVCWxm6MoJDoamvGnt8GtHKWuq85Dbqi Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=alain.frisch@lexifi.com; spf=None smtp.mailfrom=alain.frisch@lexifi.com; spf=None smtp.helo=postmaster@mx20.yaziba.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=pra; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=mailfrom; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mx20.yaziba.net) identity=helo; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="postmaster@mx20.yaziba.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ClAAAj3DVXkKTM6VVehDe8LoYUAoEwOxEBAQEBAQEBAREBAQEBCQsJCSEvgi2CFgEBBDhRCxguVwYBDAgBAYgvwEoBCwEkhiWBdoJXhD+FWQEEmCeBVoxIgWmET4MHI4U3jz8CNoIxAREKgU2JRgEBAQ X-IPAS-Result: A0ClAAAj3DVXkKTM6VVehDe8LoYUAoEwOxEBAQEBAQEBAREBAQEBCQsJCSEvgi2CFgEBBDhRCxguVwYBDAgBAYgvwEoBCwEkhiWBdoJXhD+FWQEEmCeBVoxIgWmET4MHI4U3jz8CNoIxAREKgU2JRgEBAQ X-IronPort-AV: E=Sophos;i="5.24,614,1454972400"; d="scan'208";a="218189800" Received: from mx20.yaziba.net ([85.233.204.164]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 13 May 2016 15:56:34 +0200 Received: from mta10.int.yaziba.net (mta10.int.yaziba.net [10.4.20.30]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx20.yaziba.net (mx10.yaziba.net) with ESMTPS id 3C5CD1A7BB4; Fri, 13 May 2016 15:56:34 +0200 (CEST) Received: from mta10.int.yaziba.net (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTPS id 85AD7CA751; Fri, 13 May 2016 15:56:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id 74E67CA74A; Fri, 13 May 2016 15:56:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id OGatsiDOkAwl; Fri, 13 May 2016 15:56:34 +0200 (CEST) Received: from [10.0.210.108] (unknown [185.23.92.144]) by mta10.int.yaziba.net (Postfix) with ESMTPSA id 3AD3BCA671; Fri, 13 May 2016 15:56:34 +0200 (CEST) To: Pierre Chambart , "Soegtrop, Michael" , "caml-list@inria.fr" References: <0F7D3B1B3C4B894D824F5B822E3E5A172CEF1630@IRSMSX102.ger.corp.intel.com> <850765ff-25f1-ecb9-9707-74d3dc47675c@lexifi.com> <5735DBB9.5050101@ocamlpro.com> From: Alain Frisch Message-ID: <44df5d5e-8ad9-1a86-7fda-bfc203bfb479@lexifi.com> Date: Fri, 13 May 2016 15:56:32 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <5735DBB9.5050101@ocamlpro.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeekledrvddugdeilecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpjgetkgfkueetnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeehnecuhfhrohhmpeetlhgrihhnucfhrhhishgthhcuoegrlhgrihhnrdhfrhhishgthheslhgvgihifhhirdgtohhmqeenucfkphepudekhedrvdefrdelvddrudeggeenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] Specify the default hash function for a type FWIW, I was not seriously suggesting this. That said, ..., the case should be relatively safe, since the code generated by OCaml never reads the tag of record values (it is assumed to be 0). The tag should only be read by polymorphic primitives, which don't receive any information from the OCaml optimizer. So I don't see how the optimizer could break the (not-really-)suggested hack, except on purpose. Alain On 13/05/2016 15:50, Pierre Chambart wrote: > For those who don't see that as a joke, please forget everything about that. > Obj.set_tag is an extremely dangerous function as the compiler assumes that > value's tag never change, even for completely unknown values. Hence, it > might > be legal for the compiler to do something that you might not expect on: > > let f x = > let x' = Obj.repr x in > let tag = Obj.tag x' in > Obj.set_tag x' 0 > let ... = match x with ... in > Obj.set_tag x' tag; > match x with ... > > The access to the tag can be shared for instance. And lots of > 'surprising' stuff might happen. > This is of course a quite brutal example but this could apply to a lot > of less obvious situation ! > > So Obj.magic and Obj.set_field : bad > Obj.set_tag: really really bad ! >