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: Mon, 5 Apr 2021 20:19:22 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

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, etc.) compile with -Wno-sign-compare because gcc -Wsign-compare has too many false alarms.

I prefer to avoid casts merely to pacify GCC (as casts are too error-prone), so I installed the attached. I hope it works for you. (If not, perhaps you can use -Wno-sign-compare too....)

This underscores the fact that the xalloc module should use idx_t instead of size_t pretty much everywhere. If xrealloc's size arg were of idx_t we wouldn't need any of this hacking. I realize that replacing size_t with idx_t is an incompatible change to xalloc's API, but it's time callers started using signed instead of unsigned byte counts as that helps avoid and/or catch integer-overflow errors better. I'll add that to my list of things to do for Gnulib.

Attachment: 0001-xalloc-try-to-pacify-gcc-Wsign-compare.patch
Description: Text Data


reply via email to

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