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: Paul Eggert
Subject: Re: New function xpalloc in module xalloc
Date: Tue, 6 Apr 2021 13:07:56 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

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, I wouldn't use a cast; I'd assign the integer to an uintmax_t local value, and use that.

And anyway, for this particular case widening to uintmax_t is not necessary; it complicates the code and can make it less efficient on some platforms by forcing an unnecessary conversion at runtime. So let's not do that.



reply via email to

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