bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: bug-gnulib@gnu.org
Subject: INT_ADD_WRAPV and friends considered harmful
Date: Mon, 12 Aug 2019 17:47:17 +0300	[thread overview]
Message-ID: <837e7itp8q.fsf@gnu.org> (raw)

Please take a look at the problem described in this bug report:

  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37006

The upshot is that an innocent use of INT_ADD_WRAPV, even by
experienced programmers, can quite unexpectedly produce spectacular
failures.  Frankly, I was astonished to discover this failure mode,
especially as it isn't clearly documented in the comments in
intprops.h.

AFAIU, INT_ADD_WRAPV and its ilk are safety devices: they prevent code
from failing in subtle and rare situations.  And safety devices cannot
themselves be unsafe, because that would contradict the raison d'être
of their very existence.

So I urge the Gnulib developers to please fix this deficiency, and
make these macros safe in such simple use cases.

TIA


             reply	other threads:[~2019-08-12 14:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12 14:47 Eli Zaretskii [this message]
2019-08-15  0:48 ` INT_ADD_WRAPV and friends - bug fixed Paul Eggert
2019-08-15 14:09   ` Eli Zaretskii

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=837e7itp8q.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=bug-gnulib@gnu.org \
    /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).