This is the mail archive of the gcc@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]

-Wconversion


I don't understand the output from -Wconversion.

The following program is stored in the file test.c:

  #include <stdio.h>
  
  static void foo(unsigned char ch) {
  
      printf("%c\n", ch);
  }
  
  int main(int argc, char **argv) {
  
      unsigned char bar = 'a';
  
      foo(bar);
  
      return 0;
  }
  
  > gcc -Wconversion test.c
  test.c: In function `main':
  test.c:12: warning: passing arg 1 of `foo' with different width
  due to prototype

I can't match this behavior with the documentation:

 `-Wconversion'
     Warn if a prototype causes a type conversion that is different
     from what would happen to the same argument in the absence of a
     prototype.  This includes conversions of fixed point to floating
     and vice versa, and conversions changing the width or signedness
     of a fixed point argument except when the same as the default
     promotion.

     Also, warn if a negative integer constant expression is implicitly
     converted to an unsigned type.  For example, warn about the
     assignment `x = -1' if `x' is unsigned.  But do not warn about
     explicit casts like `(unsigned) -1'.

The test program above don't causes any conversion and should
therefore not give any warning?

Seconldy, why is "different from what would happen to the same argument in
the absence of a prototype" included? This seems to be something
that belongs to -Wtraditional rather than -Wconversion.

Confusing!

--
Patrik Hägglund

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