-Wconversion considers unsigned short int unequal to itself?
Marc Glisse
marc.glisse@normalesup.org
Tue Feb 23 09:11:00 GMT 2010
On Mon, 22 Feb 2010, Davies, Aaron wrote:
> I discoved the following behavior while trying to get warnings-clean on some existing code. It was intially found in a call to ntohs(3); the below snippet isolates it. Is this warning expected?
>
> $ gcc --version
> gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> $ cat test.c
> int f(unsigned short int i){return i;}
> int main(int c,char**v){return f((unsigned short int)0);}
> $ gcc -Wall -Wconversion test.c
> test.c: In function 'main':
> test.c:2: warning: passing argument 1 of 'f' with different width due to prototype
gcc-4.3 and later don't give this warning anymore.
--
Marc Glisse
More information about the Gcc-help
mailing list