This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran, patch] reduce noise of -Wconversion
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 8 May 2010 20:52:02 +0200
- Subject: Re: [fortran, patch] reduce noise of -Wconversion
- References: <201005081915.53758.franke.daniel@gmail.com> <4BE5AAB5.90007@net-b.de>
On Saturday 08 May 2010 20:17:25 Tobias Burnus wrote:
> Daniel Franke wrote:
> > attached patch attempts to reduce amount of noise generated by
> > -Wconversion.
>
> The changes make sense to me, however, I am wondering whether we need
> some -Wconversion-extra option. The current -Wconversion option is very
> verbose, but it allowed me to find bugs such as:
>
> double_var = sqrt(2.0)
>
> where the RHS should be: "sqrt(2.0d0)". The current warning allows one
> to find it (buried in tons of other messages) - but with the proposed
> patch, this information is no longer available. I would like to get some
> warning for (REAL/COMPLEX less precision) -> (REAL/COMPLEX higher
> precision) back. I personally do not mind to have an extra option for
> this. Thus, -Wall -Wextra finds both problems, but one can then be
> disabled.
Hi Tobias,
I think we should aim for the least amount of surprise. Lot's of people
complained about the noisy behaviour and asked to get rid of the warnings for
those perfectly valid conversions. If I read c-common.c (conversion_warning)
correctly, then there's no warning for such less-to-higher precision in C.
Test ...
$> cat conversion.c
#include <math.h>
double f(float x) {
return sqrt(x);
}
$> gcc-svn -Wall -Wconversion -c conversion.c
[no warning]
$ cat conversion.c
#include <math.h>
float f(double x) {
return sqrt(x);
}
$ gcc-svn -Wall -Wconversion -c conversion.c
conversion.c: In function 'f':
conversion.c:3:3: warning: conversion to 'float' from 'double' may alter its
value [-Wconversion]
> I think regarding disabling, I like the new middle-end feature, which
> prints the warning flag in squared brackets after the warning message
> -fdiagnostics-show-option (enabled by default), e.g.
> foo.c:4:2: warning: 'j' is used uninitialized in this function
> [-Wuninitialized]
> and with -Werror:
> foo.c:4:2: error: 'j' is used uninitialized in this function
> [-Werror=uninitialized]
> And with -fno-diagnostics-show-option the [-W...] message is not printed.
While correct, I fail to see the relationship to the patch?!
Cheers
Daniel