From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65088 invoked by alias); 11 Dec 2015 21:12:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65076 invoked by uid 89); 11 Dec 2015 21:12:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 11 Dec 2015 21:12:23 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E0EF38E70F; Fri, 11 Dec 2015 21:12:21 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-83.phx2.redhat.com [10.3.113.83]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBBLCKgr015392; Fri, 11 Dec 2015 16:12:21 -0500 Subject: Re: [PATCH v2] Do not sanitize left shifts for -fwrapv (PR68418) To: Paolo Bonzini , gcc-patches@gcc.gnu.org, joseph@codesourcery.com, jakub@redhat.com, mpolacek@redhat.com, Jan Beulich References: <1449680920-64273-1-git-send-email-pbonzini@redhat.com> From: Jeff Law Message-ID: <566B3C34.1070502@redhat.com> Date: Fri, 11 Dec 2015 21:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1449680920-64273-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg01310.txt.bz2 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