bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New function xpalloc in module xalloc


From: Marc Nieper-Wißkirchen
Subject: Re: New function xpalloc in module xalloc
Date: Tue, 6 Apr 2021 21:23:02 +0200

Am Di., 6. Apr. 2021 um 21:05 Uhr schrieb Paul Eggert <eggert@cs.ucla.edu>:
On 4/5/21 11:48 PM, Marc Nieper-Wißkirchen wrote:
> SIZE_MAX < (uintmax_t) nbytes

Eeuuw! That's a cure worse than the disease. Among other things, there
is no guarantee that PTRDIFF_MAX <= UINTMAX_MAX so in theory the
comparison could go completely awry with a sufficiently-large NBYTES.

I checked the ISO C18 standard before I wrote this. :) In 6.2.5 it says that for every signed type there is an unsigned type of the same width. Given the definitions of INTMAX_MAX and UINTMAX_MAX, I then concluded

PTRDIFF_MAX <= INTMAX_MAX <= UINTMAX_MAX.

Where is the flaw in my reasoning?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]