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]

Possibly erroneous warning w/ -Wconversion


All,
	The following code produces a warning message when the parameter is 
an unsigned short int for a function prototyped for unsigned short int while 
not producing one for the unsigned int function.

Regards,

Bill
PS. If I've forgotten some key information please feel free to request it.

test.c
----------------------------------------
void test_with_unsigned_short_int_parm(unsigned short int parm);
void test_with_unsigned_int_parm(unsigned int parm);

int main(void);

int main(void)
{
    unsigned short int value = 3;

    test_with_unsigned_short_int_parm(value);
    test_with_unsigned_int_parm(value);

    return 0;
}

/* 
   Note that it is the call to test_with_unsigned_short_int_parm that
   should not give a warning; however, it is the call 
   test_with_unsigned_int_parm that gives the warning.  This happens
   w/ gcc 2.8.1 on sparc, gcc 2.7.2.3 on Linux x86, egcs 2.92.23 on sparc,
   and egcs-2.93.04 on Linux x86.
*/

/****************************************
gcc -v  -Wconversion          -c test.c -o test.o
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.93.04/specs
gcc version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.93.04/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=93 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Wconversion -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ test.c /tmp/ccwAfbmJ.i
GNU CPP version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.93.04/../../../../i686-pc-linux-gnulibc1/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.93.04/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.93.04/cc1 /tmp/ccwAfbmJ.i -quiet -dumpbase test.c -Wconversion -version -o /tmp/ccEvqXvx.s
GNU C version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental) (i686-pc-linux-gnulibc1) compiled by GNU C version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental).
test.c: In function `main':
test.c:10: warning: passing arg 1 of `test_with_unsigned_short_int_parm' with different width due to prototype
 /usr/local/i686-pc-linux-gnulibc1/bin/as -V -Qy -o test.o /tmp/ccEvqXvx.s
GNU assembler version 2.9.1 (i686-pc-linux-gnulibc1), using BFD version 2.9.1
****************************************/
----------------------------------------
end of test.c


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