From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5899 invoked by alias); 24 Sep 2004 03:41:28 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 5892 invoked from network); 24 Sep 2004 03:41:27 -0000 Received: from unknown (HELO smtp2.libero.it) (193.70.192.52) by sourceware.org with SMTP; 24 Sep 2004 03:41:27 -0000 Received: from localhost (172.16.1.79) by smtp2.libero.it (7.0.027-DD01) id 40C7347601560605; Fri, 24 Sep 2004 05:30:24 +0200 Received: from bagio (151.42.78.220) by smtp20.libero.it (7.0.027-DD01) id 40E3F8E20359D790; Fri, 24 Sep 2004 05:30:11 +0200 Message-ID: <018901c4a1e6$d6a3b720$dc4e2a97@bagio> From: "Giovanni Bajo" To: "Mathieu Malaterre" Cc: References: <4150C8D5.7070200@nycap.rr.com> Subject: Re: Warning flags for unsigned operations (unsafe) Date: Fri, 24 Sep 2004 06:20:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at libero.it serv1 X-SW-Source: 2004-09/txt/msg01400.txt.bz2 Mathieu Malaterre wrote: > I have been googling around and I couldn't find out if gcc had a > warning flag for unsigned operation. For example, even the linear > interpolation on [a,b] can be tricky to code: > > 1. > c = a + t * (b - a); //unsafe > > 2. > c = (1.0 - t) * a + t * b; //safe > > Number 1 will fail when both a and b are unsigned and let say b - a = > -1 (math speaking). Is there something in gcc that could warn me for > this kind of operation ? Would you please file a bug report in Bugzilla and later mark it as a enhancement request? Thanks. Giovanni Bajo