public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	gcc-patches@gcc.gnu.org,        joseph@codesourcery.com,
	jakub@redhat.com, mpolacek@redhat.com,
	       Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH v2] Do not sanitize left shifts for -fwrapv (PR68418)
Date: Fri, 11 Dec 2015 21:12:00 -0000	[thread overview]
Message-ID: <566B3C34.1070502@redhat.com> (raw)
In-Reply-To: <1449680920-64273-1-git-send-email-pbonzini@redhat.com>

On 12/09/2015 10:08 AM, Paolo Bonzini wrote:
> Left shifts into the sign bit is a kind of overflow, and the
> standard chooses to treat left shifts of negative values the
> same way.
>
> However, the -fwrapv option modifies the language to one where
> integers are defined as two's complement---which also defines
> entirely the behavior of shifts.  Disable sanitization of left
> shifts when -fwrapv is in effect, using the same logic as
> instrument_si_overflow.  The same change was proposed
> for LLVM at https://llvm.org/bugs/show_bug.cgi?id=25552.
>
> Bootstrapped/regtested x86_64-pc-linux-gnu.  Ok for trunk, and for
> GCC 5 branch after 5.3 is released?
>
> Thanks,
>
> Paolo
>
> gcc:
> 	PR sanitizer/68418
> 	* c-family/c-ubsan.c (ubsan_instrument_shift): Disable
> 	sanitization of left shifts for wrapping signed types as well.
>
> gcc/testsuite:
> 	PR sanitizer/68418
> 	* gcc.dg/ubsan/c99-wrapv-shift-1.c,
> 	gcc.dg/ubsan/c99-wrapv-shift-2.c: New testcases.
Thanks for the pointers to the earlier code that constrains the types.

FWIW Jan Beulich is twiddling the code leading to the 
ubsan_instrument_shift call.  In fact, your change may make Jan's change 
safe :-)


OK for the trunk.

Thanks,
Jeff


  reply	other threads:[~2015-12-11 21:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 17:08 Paolo Bonzini
2015-12-11 21:12 ` Jeff Law [this message]
2015-12-12 21:09 ` Eric Botcazou

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=566B3C34.1070502@redhat.com \
    --to=law@redhat.com \
    --cc=JBeulich@suse.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=mpolacek@redhat.com \
    --cc=pbonzini@redhat.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).