From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21545 invoked by alias); 30 Apr 2014 06:55:22 -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 21535 invoked by uid 89); 30 Apr 2014 06:55:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS 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 ESMTP; Wed, 30 Apr 2014 06:55:20 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3U6tI3K029126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Apr 2014 02:55:18 -0400 Received: from tucnak.zalov.cz (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3U6tFJt024778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Apr 2014 02:55:16 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.8/8.14.7) with ESMTP id s3U6tCH8011082; Wed, 30 Apr 2014 08:55:13 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.8/8.14.8/Submit) id s3U6tAN1011081; Wed, 30 Apr 2014 08:55:10 +0200 Date: Wed, 30 Apr 2014 06:56:00 -0000 From: Jakub Jelinek To: Marek Polacek Cc: Tobias Burnus , Marc Glisse , GCC Patches , "Joseph S. Myers" Subject: Re: [PATCH] Implement -fsanitize=float-divide-by-zero Message-ID: <20140430065510.GS1817@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20140429082758.GA9773@physik.fu-berlin.de> <20140429084606.GO1817@tucnak.redhat.com> <20140429093450.GA11802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140429093450.GA11802@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg02029.txt.bz2 On Tue, Apr 29, 2014 at 11:34:50AM +0200, Marek Polacek wrote: > Ran ubsan testsuite (-m32/-m64) + bootstrap-ubsan on x86_64-linux, ok now? > > 2014-04-29 Marek Polacek > > * gcc.c (sanitize_spec_function): Handle SANITIZE_FLOAT_DIVIDE. > * builtins.def: Initialize builtins even for SANITIZE_FLOAT_DIVIDE. > * flag-types.h (enum sanitize_code): Add SANITIZE_FLOAT_DIVIDE. > * opts.c (common_handle_option): Add -fsanitize=float-divide-by-zero. > c-family/ > * c-ubsan.c (ubsan_instrument_division): Handle REAL_TYPEs. Perform > INT_MIN / -1 sanitization only for integer types. > c/ > * c-typeck.c (build_binary_op): Call ubsan_instrument_division > also when SANITIZE_FLOAT_DIVIDE is on. > cp/ > * typeck.c (cp_build_binary_op): Call ubsan_instrument_division > even when SANITIZE_FLOAT_DIVIDE is on. Set doing_div_or_mod even > for non-integer types. > testsuite/ > * c-c++-common/ubsan/div-by-zero-5.c: Fix formatting. > * c-c++-common/ubsan/float-div-by-zero-1.c: New test. > +int > +main (void) > +{ > + volatile float a = 1.3f; > + volatile double b = 0.0; > + volatile int c = 4; > + > + a / b; > + a / 0.0; > + 2.7f / b; > + 3.6 / (b = 0.0, b); > + c / b; > + b / c; Please assign the result of the divisions to some other volatile variables, otherwise I don't see why the compiler couldn't optimize them away all. Otherwise looks good to me. Jakub