http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53603

--- Comment #3 from Richard Neill <gcc at richardneill dot org> 2012-06-07 
14:41:10 UTC ---
Thanks for your explanation. I didn't know about -Wconversion existing
independently of -Wextra. 

Might I suggest a couple of things that arise:

1. It seems a bit strange to me that there are warnings that are not enabled by 
-Wall -Wextra. The man page lists so many different types of warning: perhaps
it would be useful to mention (under -Wextra) which ones it does *not* enable?
Or maybe it would be worthwhile adding something like "-Wkitchensink" to mean:
yes, really do turn on all the warnings (except maybe for pedantic). 

2. Even -Wconversion misses the following:

  int a=7; int b=4;
  double y;  
  y = a/b;

I know why: a/b is a perfectly sensible integer division, and then y is being
assigned the integer value of 1, which is also a loss-freel conversion.
But, what I mean by "y=a/b" is "y is the floating point number obtained by
dividing a and b", not "do integer division of a/b and then promote to a
double"

3. As you say, -Wconversion is too noisy to include by default. But perhaps
there could be a distinction between straightforward assignment: 

   int a; 
   unsigned int b;
   a=b; 

and function calls with mismatched parameters:

   int a; 
   double d;
   int myfunction(int x){...}  ; 
   a = myfunction(d);

I'd suggest that when the latter happens, it's most probably a bug, whereas the
former is (often) deliberate. This might allow for some subsets of -Wconversion
to be included within -Wextra ? 

Thanks for your time.

Reply via email to