From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8959 invoked by alias); 16 Feb 2007 20:50:25 -0000 Received: (qmail 8934 invoked by uid 48); 16 Feb 2007 20:50:16 -0000 Date: Fri, 16 Feb 2007 20:50:00 -0000 Message-ID: <20070216205016.8933.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "tkoenig at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-02/txt/msg02012.txt.bz2 ------- Comment #4 from tkoenig at gcc dot gnu dot org 2007-02-16 20:50 ------- (In reply to comment #3) > There is a new -Wconversion implementation. Perhaps you could do the same for > fortran as I did for C/C++. Take a look at c-common.c (conversion_warnings). It > would be great if -Wconversion behaves the same way (more or less) in all > front-ends. This would be a good idea. Looking at the code from c-common.c, we should warn about real(kind=4) :: a real(kind=8) :: b integer(kind=1) :: i1 integer(kind=4) :: i4 i4 = 2.3 ! Not exact i1 = 500 ! doesn't fit a = 2**26-1 ! Loses bits of precision b = 1d99 ! Doesn't fit the type a = i4 ! may lose extra digits b = i4 ! This is OK (enough digits in the kind=8 var) i1 = i4 ! i1 may not be able to represent the values in i4 a = b ! precision loss For Fortran, we should also warn about b = 2.5 print *,b**(3/2) ! identical to b**1, usually unintended and maybe even about print *,4/3 ! constant integer division -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866