This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc's -Wconversion
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Geoff Thorpe <geoff at geoffthorpe dot net>
- Cc: Agthorr <agthorr at barsoom dot org>, Segher Boessenkool <segher at koffie dot nl>, <bangerth at dealii dot org>, <128950 at bugs dot debian dot org>, <gcc-bugs at gcc dot gnu dot org>, <josh dot dybnis at sandtechnology dot com>
- Date: Thu, 6 Feb 2003 22:57:33 +0000 (GMT)
- Subject: 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