From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 80FBC3858D28 for ; Tue, 20 Jun 2023 10:50:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 80FBC3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687258245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ae65BAnAET6iN/feUbj4BxpHniknwhQKSnvsA1nzGmY=; b=A24rrPlhPWDA9z9aRhTvti0QHlaV+qLAo2t8rKSgw7kOU5o5iIBW3lL9oYUVY8KG2FoKXK RMqbPFETyWS7MP3gu34/d7xu2Xm3ovoDvQW4Ti/gCBPee+QEpWb3XioiI/pfG06jH2A5f8 FkIOQqcXPO4O+kcZaJ4/kFNL+Q1y7aM= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-RKL5DS93MrSbrHvb72Hj_Q-1; Tue, 20 Jun 2023 06:50:41 -0400 X-MC-Unique: RKL5DS93MrSbrHvb72Hj_Q-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2b45e6e1c44so30772831fa.2 for ; Tue, 20 Jun 2023 03:50:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687258240; x=1689850240; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ae65BAnAET6iN/feUbj4BxpHniknwhQKSnvsA1nzGmY=; b=DteVbg5MjpFSda4QeZiSvnZvt5dET2mQh/jnzZdL1wzz9HwtSQ8vPuD+So9pMVHxSO x+R7WFpXeieqpHz6wgT1qOSGupPRU16fDGBxR1/PWY4CgtTIfnY+L3sm7vhek8dBHh3w bo1UONgjDo0PeGHfhuLzW5wHH/vs3oSiDMPpnE1MqJCcJ5FODUbA5Uyspj+fU8GXK57k IxZ8rZ2R99Uebxp2pqrrUFh8ruqCEtmSguwZnTTFOEPR+NbgHZMc9Md7jGHR+bnTY0Fp IfitHMP55OMzi2PLUYMRwBPeGoWGAumQW04MzO8BbsBRzpYYt1eFXS6tzjA0n0fNL/4b ZCUQ== X-Gm-Message-State: AC+VfDwvEszH9eZD5ytl3mT7IY/bWov/QHf8YLdGHlrselDyKkhThnYZ EIHbBm8aERrDdYSHv+nv8JyOO2maelSfswpACDxIRDQYaOzFSgypqGb9AofKkqDojB6pl0twNTA q8mGqn8FSEY2huD1JSzKmy0XMLX2d/Y5XEf8DIAjW/A== X-Received: by 2002:a2e:9b4f:0:b0:2b4:70da:823 with SMTP id o15-20020a2e9b4f000000b002b470da0823mr4174849ljj.45.1687258240315; Tue, 20 Jun 2023 03:50:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4RAEub4PQrVqruZSSlMjtp/Fog6KB6sT60hcOPrE/kmyHLOEzDTCxB2JER8yIkzx+iBr9k6uDIwIzbD7MSO4I= X-Received: by 2002:a2e:9b4f:0:b0:2b4:70da:823 with SMTP id o15-20020a2e9b4f000000b002b470da0823mr4174835ljj.45.1687258240058; Tue, 20 Jun 2023 03:50:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Tue, 20 Jun 2023 11:50:28 +0100 Message-ID: Subject: Re: [libstdc++] Improve M_check_len To: Andreas Schwab Cc: Jakub Jelinek via Gcc-patches , Jan Hubicka , Jakub Jelinek , "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="0000000000000b1cd305fe8d6c87" X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000000b1cd305fe8d6c87 Content-Type: text/plain; charset="UTF-8" On Tue, 20 Jun 2023 at 11:45, Jonathan Wakely wrote: > On Tue, 20 Jun 2023 at 09:21, Andreas Schwab wrote: > >> On Jun 20 2023, Jakub Jelinek via Gcc-patches wrote: >> >> > Is it safe even on 64bit targets? I mean, doesn't say PowerPC already >> allow >> > full 64-bit virtual address space? The assumption that one can't have >> > more than half of virtual address space allocations is true right now at >> > least on x86-64, aarch64 and others, but isn't that something that can >> > change with newer versions of CPUs without the need to recompile >> > applications (add another level or two of page tables)? >> >> At least s390 can allocate more than half the address space. That >> triggered a failure in gawk. >> > > Is PTRDIFF_MAX large enough to represent the difference between any two > pointers? > > What we're considering for libstdc++ is treating PTRDIFF_MAX as an upper > limit on allocation size. If there are targets that can really allocate a > 2^63 byte array, they won't be able to represent the difference between the > first element and the last element unless ptrdiff_t is wider than 64 bits. > Of course if we're talking about 32-bit targets then you only need a 64-bit ptrdiff_t to allow arrays larger than 2^31 bytes. In any case, PTRDIFF_MAX is still an upper limit (although for a 64-bit ptrdiff_t and a 32-bit address space, it's not a useful limit, because it's much much larger than the real limit). --0000000000000b1cd305fe8d6c87--