bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>
Cc: "bug-gnulib@gnu.org List" <bug-gnulib@gnu.org>
Subject: Re: New function xpalloc in module xalloc
Date: Sun, 4 Apr 2021 02:23:57 -0400	[thread overview]
Message-ID: <CAH8yC8mest8Po9NdmQ3qv3Q391_Hj03uTrNHK4McDGkSZ6rtxw@mail.gmail.com> (raw)
In-Reply-To: <CAEYrNrTWcLXUWw_Fno_-S3cfs-iDoA-5Kd0TfCHqpSB8tbw6Ow@mail.gmail.com>

On Sun, Apr 4, 2021 at 2:17 AM Marc Nieper-Wißkirchen
<marc.nieper+gnu@gmail.com> 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' {aka 'long int'} [-Wsign-compare]
>   132 |     = ((INT_MULTIPLY_WRAPV (n, item_size, &nbytes) || SIZE_MAX < nbytes)
>
> If I understand the error message correctly, it is because 'nbytes' is a signed type while SIZE_MAX is unsigned.
>
> Does the comparison make any sense, by the way?

Only for positive integers.

If idx_t is negative, like -1, then -1 will be promoted to an unsigned
type and then -1 > 0.

Jeff


  reply	other threads:[~2021-04-04  6:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-04  6:17 New function xpalloc in module xalloc Marc Nieper-Wißkirchen
2021-04-04  6:23 ` Jeffrey Walton [this message]
2021-04-04  6:43   ` Marc Nieper-Wißkirchen
2021-04-06  3:19 ` Paul Eggert
2021-04-06  6:48   ` Marc Nieper-Wißkirchen
2021-04-06 19:05     ` Paul Eggert
2021-04-06 19:23       ` Marc Nieper-Wißkirchen
2021-04-06 20:07         ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH8yC8mest8Po9NdmQ3qv3Q391_Hj03uTrNHK4McDGkSZ6rtxw@mail.gmail.com \
    --to=noloader@gmail.com \
    --cc=bug-gnulib@gnu.org \
    --cc=marc.nieper+gnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).