public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: DJ Delorie <dj@redhat.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>, libc-alpha@sourceware.org
Subject: Re: [patch] Use unsigned constants for ICMP6 filters [BZ #22489]
Date: Sun, 26 Apr 2020 14:25:56 +0300 (MSK)	[thread overview]
Message-ID: <alpine.LNX.2.20.13.2004261416540.31260@monopod.intra.ispras.ru> (raw)
In-Reply-To: <xnsggr9rap.fsf@greed.delorie.com>

Computing 1<<31 causes undefined behavior (signed overflow), you get
a warning with -Wshift-overflow=2 and a runtime error with UBSan,
i.e. with -fsanitize=undefined.

I'd say the situation with -Wsign-conversion warning is more subtle
than your initial mail seemed to imply, normally gcc suppresses warnings
for code originating in system headers unless -Wsystem-headers is also
specified. Here the warning appears where user code expands a macro
defined in a system header, maybe this situation is not properly
handled for -Wsign-conversion in GCC.

In summary, you need 1u to avoid causing undefined behavior if
a shift left by 31 is possible in practice, and it also happens to
suppress GCC's -Wsign-conversion warning (while there's
nothing undefined about the conversion itself).

Alexander

  reply	other threads:[~2020-04-26 11:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 21:35 DJ Delorie
2020-04-25  8:53 ` Andreas Schwab
2020-04-25 17:15   ` DJ Delorie
2020-04-25 17:48     ` Andreas Schwab
2020-04-25 21:23       ` DJ Delorie
2020-04-25 21:30         ` Andreas Schwab
2020-04-25 21:41           ` DJ Delorie
2020-04-26 11:25             ` Alexander Monakov [this message]
2020-04-26 11:56               ` Florian Weimer
2020-04-30 20:47                 ` DJ Delorie
2020-05-03 20:23                   ` Florian Weimer
2020-05-08 20:10                     ` DJ Delorie
2020-05-08 20:22                       ` Florian Weimer
2020-05-11 21:09                         ` DJ Delorie
2020-05-12  7:35                       ` Andreas Schwab
2020-04-26  8:03 ` Florian Weimer

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

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

  git send-email \
    --in-reply-to=alpine.LNX.2.20.13.2004261416540.31260@monopod.intra.ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=dj@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.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).