From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id ED76C1F463 for ; Sat, 14 Dec 2019 02:35:36 +0000 (UTC) Received: from localhost ([::1]:55428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifxHL-0002RP-Bi for normalperson@yhbt.net; Fri, 13 Dec 2019 21:35:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48139) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifxHE-0002NF-H9 for bug-gnulib@gnu.org; Fri, 13 Dec 2019 21:35:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ifxHC-0003lQ-JW for bug-gnulib@gnu.org; Fri, 13 Dec 2019 21:35:28 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::6]:13522) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ifxHB-0003aC-QP for bug-gnulib@gnu.org; Fri, 13 Dec 2019 21:35:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1576290922; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=Ev03uCMs/vppgxBAsLzHJdUTYsChis+uV+SVApO/y18=; b=Cv6Z64e4Q9yOplp2bx698eMY3GuXZQLZesPNT8gFV8DMq0KH086IjO7Jg5DeBdCTSM alg+RN9cFdZRKMoZefsRFXdKZSakoO9kA/QPYuzLB9Hhr1BgeYEpLStvtC1ZsDV/js/r 6gNGcZubtzhZfIlhH6ji/2ybJ2YM2UO0qL4ZtlXFyYzyPGvnQErqmYrB5IKiowTYyOOE LGMG6i0ECxkVA3a+Y19fNwBauUAk/OUCFrfaJrN8Mvo9A5EM5OV/0UeEIsd9EIq35YJ7 52hFAHdp/qg5SETTeoz3LzJ9ykoVQsHGWJ0aEGLPRKz8Y+uyTCWDMSWxxytkH742JLim luzA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.0.7 DYNA|AUTH) with ESMTPSA id 3049ecvBE2Z99Sc (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sat, 14 Dec 2019 03:35:09 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: intptr_t vs. uintptr_t Date: Sat, 14 Dec 2019 03:35:09 +0100 Message-ID: <2169340.l2UmpkpDhn@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20db9cb5-da09-fe26-f7fc-884fc194daaa@cs.ucla.edu> References: <20190323080618.E6EB.27F6AC2D@kcn.ne.jp> <20db9cb5-da09-fe26-f7fc-884fc194daaa@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::6 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Paul Eggert wrote: > https://www.gnu.org/software/emacs/manual/html_node/elisp/C-Integer-Types.html Quoting it: "Prefer intptr_t for internal representations of pointers" I disagree with this advice. uintptr_t ought to be used for representing the address of a pointer. Why? Because when signed comparisons or pointer differences come into play, - uintptr_t creates a boundary line at 0x00000000, - intptr_t creates a boundary line at 0x80000000. Now look at the virtual memory map of a process (e.g. by compiling vma-iter.c with -DTEST). On all OSes, there is a natural boundary line at 0x00000000 - simply because there is the null-pointer catching area there. On many OSes, memory allocations can lie around 0x80000000. So, it is possible to have ptr1 = 0x7fffc000 and ptr2 = 0x80003000 point into the same object (allocated through mmap or malloc). Then - you DO want ptr1 < ptr2 to evaluate to true, not false, - you DO want ptr2 - ptr1 to evaluate to 0x7000, not to a signed integer overflow. Bruno