Path: csiph.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.uzoreto.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: Is this really necessary
Date: Tue, 10 Aug 2021 07:13:59 -0700
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <86tujxz8t4.fsf@linuxsc.com>
References: <86im0h2fi1.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="8983d14e45a299e43fc74f5563f3d6b2"; logging-data="23323"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Opg7XsK5BeURjP66SbcGV6dL/aM5VunE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Nbdn3nVptL37yW6hVlNXA+QuyrE= sha1:AZ5sqAiB6fA9wbprumX6OFXqRoI=
Xref: csiph.com comp.lang.c++:80826
Richard Damon writes:
> On 8/9/21 4:50 PM, Vir Campestris wrote:
[...]
>> As it happens it's never been a practical problem as I've never had a 32
>> bit system with more than 2GB RAM, and don't expect the 64 bit limit to
>> be a problem any time soon.
>
> Since for 16 bit size_t ptrdiff_t has a requirement to be at least 17
> bits, I think the committee decided that it was unlikely for an
> application with a 32-bit address space to have over half of its memory
> dedicated to a single char array (the only real case where you can have
> this issue).
A few weeks ago I happened to write a small C program that does
part of its work in a single large dynamically allocated memory
area. In that memory area there are character arrays, character
pointers, and various offset values (unsigned integers). The
program runs just fine on a 64-bit linux system (in one case the
memory area allocated was about 180 GB).
Prompted by this discussion, I took the program and tried
compiling and running it on a 32-bit linux system. The memory
area allocated was a little over 2 GB, and the program fell down
miserably. Limiting the size of the memory area allocated to
PTRDIFF_MAX, with no other changes, got it working again. So
problems due to the limited range of ptrdiff_t definitely can
occur in practical programs.
> [...]
>
> From what I remember of minumum limits, a machine with only 64k
> of address space can't really be fully conforming, [...]
The rule for being able to have a 64 KB object applies only to
hosted implementations. It's easy to make a fully conforming
freestanding implementation for a machine with limited address
space, even one much less than 64 KB.