Path: csiph.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: Wed, 11 Aug 2021 05:26:13 -0700 Organization: A noiseless patient Spider Lines: 29 Message-ID: <86h7fwyxp6.fsf@linuxsc.com> References: <86im0h2fi1.fsf@linuxsc.com> <8635rh1m2i.fsf@linuxsc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="9b2de4ec06692993da9b82e10a905748"; logging-data="5074"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Gu6XmLoiu8R5qR+Hp7rc+Z5WQWz6tUbU=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:3MVJyo1sfehi9Urgl/JXNpcyakA= sha1:/2SWtIJSOHxhJZtc14QEK357usg= Xref: csiph.com comp.lang.c++:80849 Juha Nieminen writes: > Tim Rentsch wrote: > >> Vir Campestris writes: >> >> [..stuff about 64 bit systems removed..] >> >>> What bothers me about ptr_diff_t is the size. The difference between >>> two 32-bit pointers is plus or minus 4GB. Which needs a 33 bit value >>> :( >>> >>> As it happens it's never been a practical problem as I've never had a >>> 32 bit system with more than 2GB RAM, >> >> It isn't necessary for there to be more than 2GB of RAM for >> problems with ptrdiff_t to manifest (in 32-bit linux). A call to >> malloc() will gladly return a memory area larger than all of RAM >> if there is swap space to hold it. > > Also, doesn't mmap() in Linux map a file into "virtual memory"? > Ostensibly this can be larger than the amount of physical RAM. That's a more complicated question. I don't see anything in the documentation that rules out mapping a file larger than physical RAM, but I also don't see any indication that such cases must be supported, even if only conditionally supported. My comment about malloc() is based on first-hand experience; I don't have any corresponding first-hand experience with mmap().