On 4/6/21 12:23 PM, Marc Nieper-Wißkirchen wrote:
Where is the flaw in my reasoning?
Oh, you're right; any nonnegative signed integer value will fit into
uintmax_t. (Perhaps this wasn't always true in older standards, but it's
true of the recent C standard.)
So that cast should work. Still,
Am Di., 6. Apr. 2021 um 21:05 Uhr schrieb Paul Eggert :
> 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 c
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.
"Don'
Hi Paul,
Am Di., 6. Apr. 2021 um 05:19 Uhr schrieb Paul Eggert :
> On 4/3/21 11:17 PM, Marc Nieper-Wißkirchen wrote:
> > Does the comparison make any sense, by the way?
>
> Yes, although it's needed only on unusual (and these days perhaps
> theoretical?) platforms where SIZE_MAX < PTRDIFF_MAX.
>
On 4/3/21 11:17 PM, Marc Nieper-Wißkirchen wrote:
Does the comparison make any sense, by the way?
Yes, although it's needed only on unusual (and these days perhaps
theoretical?) platforms where SIZE_MAX < PTRDIFF_MAX.
I hadn't noticed the issue, as the projects I contribute to (coreutils,
e
SIZE_MAX could be defined as -1 promoted to an unsigned type, meaning that
the unsigned comparison would always yield false. Or am I missing something?
In any case, if the promotion is what is intended, 'nbytes' should be
probably replaced with '(size_t) nbytes' to silence the warning and to make
On Sun, Apr 4, 2021 at 2:17 AM Marc Nieper-Wißkirchen
wrote:
>
> GCC prints the following warning when compiling the new code:
>
> lib/xmalloc.c: In function 'xpalloc':
> lib/xmalloc.c:132:64: warning: comparison of integer expressions of different
> signedness: 'long unsigned int' and 'idx_t' {a
GCC prints the following warning when compiling the new code:
lib/xmalloc.c: In function 'xpalloc':
lib/xmalloc.c:132:64: warning: comparison of integer expressions of
different signedness: 'long unsigned int' and 'idx_t' {aka 'long int'}
[-Wsign-compare]
132 | = ((INT_MULTIPLY_WRAPV (n, ite