public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Richard Biener <rguenther@suse.de>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Remove -fstrict-overflow, default to undefined signed integer and pointer overflow
Date: Thu, 27 Apr 2017 16:13:00 -0000	[thread overview]
Message-ID: <b378ccf4-b3d7-8ae7-0b9c-d1e845169a17@redhat.com> (raw)
In-Reply-To: <alpine.LSU.2.20.1704261316060.17885@zhemvz.fhfr.qr>

On 04/26/2017 05:31 AM, Richard Biener wrote:
> 
> The following removes the third state we had apart from signed integer
> overflow wrapping and being undefined.  It makes signed integer overflow
> undefined, consistently at all optimization levels.  -fno-strict-overflow
> stays as a backward compatible way to avoid optimizations that rely on
> signed integer overflow being undefined by making it wrapping
> (this is also the reason of using !flag_wrapv in
> POINTER_TYPE_OVERFLOW_UNDEFINED rather than a new option, for now).
> 
> Surprisingly there's no UBSAN integer overflow testsuite fallout,
> foldings that happen before instrumentation (which is done after
> into-SSA) and rely on signed integer overflow being undefined will
> cause false negatives.  If that turns out to be a problem the
> flag_strict_overflow flag can be re-introduced (not that this would
> be my preference) and it can be unset after UBSAN instrumentation
> is finished.
> 
> The main motivation for aliasing -fstrict-overflow to -f[no-]wrapv
> is that with -fno-strict-overflow (and thus -O1 at the moment) you get
> the worst of both worlds, you can't optimize based on the undefinedness
> but you also cannot rely on wrapping behavior (to know that
> re-association will not introduce undefined behavior).  Using -fwrapv
> for -fno-strict-overflow makes it clear what the semantics are.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> I opened PR80525 for the appearant mishandling of (a + 1) && (a + 1)
> with -Wlogical-op when overflow is undefined.
> 
> If there are no further comments I plan to install this after 7.1
> is released.  I consider the Ada FE change obvious.
> 
> The next step is to get rid of all that ugly -Wstrict-overflow code
> in VRP.  strict-overflow warnings from folding were already
> detoriating with moving stuff to match.pd where it isn't easy to
> preserve those.  Ripping those out can be done later, it's not
> blocking other stuff, and eventually somebody picks up -Wstrict-overflow
> to warn for some cases from the FEs.
> 
> changes.html/porting_to.html will need to have instructions how to
> use ubsan to get at the real problems in code.
This all sounds good to me.

jeff

  parent reply	other threads:[~2017-04-27 15:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 12:03 Richard Biener
2017-04-26 22:05 ` Eric Botcazou
2017-04-27 16:13 ` Jeff Law [this message]
2017-05-05 15:07   ` Christophe Lyon

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=b378ccf4-b3d7-8ae7-0b9c-d1e845169a17@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /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).