This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran, patch] reduce noise of -Wconversion


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]