From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11800 invoked by alias); 22 Sep 2004 00:35:40 -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 11792 invoked from network); 22 Sep 2004 00:35:39 -0000 Received: from unknown (HELO ms-smtp-04.nyroc.rr.com) (24.24.2.58) by sourceware.org with SMTP; 22 Sep 2004 00:35:39 -0000 Received: from [192.168.0.49] (alb-24-195-142-251.nycap.rr.com [24.195.142.251]) by ms-smtp-04.nyroc.rr.com (8.12.10/8.12.10) with ESMTP id i8M0ZbIh017302 for ; Tue, 21 Sep 2004 20:35:37 -0400 (EDT) Message-ID: <4150C8D5.7070200@nycap.rr.com> Date: Wed, 22 Sep 2004 05:33:00 -0000 From: Mathieu Malaterre User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040803 MIME-Version: 1.0 To: gcc@gcc.gnu.org Subject: Warning flags for unsigned operations (unsafe) Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine X-SW-Source: 2004-09/txt/msg01260.txt.bz2 Hello, 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 ? Thanks, Mathieu