gcc's -Wconversion

Joseph S. Myers jsm28@cam.ac.uk
Thu Feb 6 22:57:00 GMT 2003


On Thu, 6 Feb 2003, Geoff Thorpe wrote:

>   void foo(unsigned short b)
>   {
>       foo(b + 1);
>   }
> 
> compiled with "gcc -Wconversion" gives the dreaded "warning: passing arg
> 1 of `foo' with different width due to prototype".

But in this particular case, the warning is correct.  b gets promoted to 
int in the expression, and b+1 has type int, and (if b == USHRT_MAX) the 
implicit conversion can change the value.

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-bugs mailing list