-Wconversion considers unsigned short int unequal to itself?

Davies, Aaron Aaron.Davies@morganstanley.com
Mon Feb 22 23:39:00 GMT 2010


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
--------------------------------------------------------------------------
NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We may monitor and store emails to the extent permitted by applicable law.



More information about the Gcc-help mailing list