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


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