From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8287 invoked by alias); 27 Sep 2013 07:58:02 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 8275 invoked by uid 89); 27 Sep 2013 07:58:01 -0000 Received: from ypig.lip.ens-lyon.fr (HELO ypig.lip.ens-lyon.fr) (140.77.13.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 27 Sep 2013 07:58:01 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.9 required=5.0 tests=AWL,BAYES_50,NO_RELAYS,SPAM_SUBJECT autolearn=no version=3.3.2 X-HELO: ypig.lip.ens-lyon.fr Received: from vlefevre by ypig.lip.ens-lyon.fr with local (Exim 4.80) (envelope-from ) id 1VPSw1-0000Tn-Qe; Fri, 27 Sep 2013 09:57:57 +0200 Date: Fri, 27 Sep 2013 07:58:00 -0000 From: Vincent Lefevre To: gcc-help@gcc.gnu.org Subject: Re: how to make gcc warn about arithmetic signed overflow Message-ID: <20130927075757.GA10027@ypig.lip.ens-lyon.fr> Mail-Followup-To: gcc-help@gcc.gnu.org References: <20130923000355.fa2a964c.jklowden@schemamania.org> <52409B07.1070002@redhat.com> <20130923180022.b06c9ae2.jklowden@schemamania.org> <5241D058.6000209@redhat.com> <20130925222958.63f91bc9.jklowden@schemamania.org> <20130926082941.GA31230@ypig.lip.ens-lyon.fr> <52444961.6030103@redhat.com> <20130926170232.GA8435@xvii.vinc17.org> <52446F22.3040205@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52446F22.3040205@redhat.com> X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6305-vl-r59709 (2013-04-16) X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00190.txt.bz2 On 2013-09-26 18:30:10 +0100, Andrew Haley wrote: > On 09/26/2013 06:02 PM, Vincent Lefevre wrote: > > On 2013-09-26 15:49:05 +0100, Andrew Haley wrote: > >> On 09/26/2013 09:29 AM, Vincent Lefevre wrote: > >>> On 2013-09-25 22:29:58 -0400, James K. Lowden wrote: > >>>> You mean that a naïve rendering of the source code implies an overflow > >>>> where none might exist in the actual emitted object code. And, > >>>> presumably, the converse: that even if the source is written such that > >>>> there logically can't be an overflow, the compiler might render object > >>>> code that does. > >>> > >>> The converse is forbidden. > >> > >> You'll find it hard to justify that by any language in the standard. > > > > What do you mean? > > There is no reason why a compiler should not generate an overflow > where none is written in the program, as long as it doesn't generate > a different result. OK, I wouldn't call that an overflow, then. I thought you meant rewrite the code in an intermediate step, generating an overflow, before knowing the consequences at the target level. The term "overflow" has a connotation of exception / undefined behavior. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)