From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16305 invoked by alias); 13 Jul 2006 07:53:52 -0000 Received: (qmail 16295 invoked by uid 22791); 13 Jul 2006 07:53:51 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 13 Jul 2006 07:53:48 +0000 Received: from stewie.corp.google.com (stewie.corp.google.com [172.24.0.49]) by smtp-out.google.com with ESMTP id k6D7rZgt006307; Thu, 13 Jul 2006 08:53:36 +0100 Received: from smtp.google.com (baraddur.corp.google.com [192.168.15.228]) by stewie.corp.google.com with ESMTP id k6D7rVqU031584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 13 Jul 2006 00:53:32 -0700 Received: from localhost.localdomain.google.com (adsl-71-133-8-30.dsl.pltn13.pacbell.net [71.133.8.30]) (authenticated bits=0) by smtp.google.com (8.13.7/8.13.6) with ESMTP id k6D7rVEv008541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 13 Jul 2006 00:53:31 -0700 To: "Scott Lipcon" Cc: lopezibanez@gmail.com, gcc-help@gcc.gnu.org Subject: Re: floating point warnings, and gcc 4 warnings in general References: <580cd3b30607120744r7d673234waf810673d9b63d2@mail.gmail.com> From: Ian Lance Taylor Date: Thu, 13 Jul 2006 07:53:00 -0000 In-Reply-To: <580cd3b30607120744r7d673234waf810673d9b63d2@mail.gmail.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-07/txt/msg00159.txt.bz2 "Scott Lipcon" writes: > I'm trying to figure out how to get gcc to warn on a specific problem > that we found in our source code. I've attached a simple test > program that has a few places where floating point precision can > potentially be lost or cause problems. Specifically: > 1) Line 12, returns a double as a float without an explicit > cast - loss of precision. Would like a warning here. > 2) Line 19, same problem, but with fixed point - returns an int > as a short, without a cast - loss of precision, would like a warning > 3) Line 31, subtracts a float from a double (the constant is > treated as a double, the variable is explicitly cast as a float. In > this particular case, as can be seen in the printf on line 34, pi/2 - > pi/2 does not equal zero. This seems like it might be harder to > check for, but I'd love to see a warning here as well. Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez is working on warnings along these lines= as part of a Google Summer of Code project. See http://gcc.gnu.org/wiki/Wcoercion Ian