[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#128950: gcc's -Wconversion



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




Reply to: