incorrectly warns: warning: passing arg 1 of `func' with different width due to prototype when compiling: void func (short); void short_test (void) { short x = 0; func(x); } with command line: gcc -Wconversion -c test.c Release: 2.95.3-6 mingw build Environment: Windows XP/mingw How-To-Repeat: gcc -Wconversion -c test.c
State-Changed-From-To: open->analyzed State-Changed-Why: Yes, this is odd. In some way the compiler is right, since if no prototype were present, the short would be converted to an int. Here, there is a prototype, so the conversion does not take place. Thus, something different is happening, which is exactly what the documentation of -Wconversion says is what it is all about. However, in this case it is clearly odd to get a message. Testcase: -------------------------------------- tmp/g> cat x.c void func (short); void short_test (void) { short x = 0; func(x); } tmp/g> /home/bangerth/bin/gcc-3.2.1-pre/bin/gcc -Wconversion -c x.c x.c: In function `short_test': x.c:4: warning: passing arg 1 of `func' with different width due to prototype
Still happens on the mainline (20030615).
*** Bug 13945 has been marked as a duplicate of this bug. ***
The problem I see here is that the error is just written wrong. I think it should say something like: warning: passing arg 1 of `func' is not converted due to a prototype.
No, the message really means what it says. This warning was designed for people who also use compilers which do not support prototypes. Nowadays, it is very unlikely to be useful for anybody; IMHO we might as well remove it.
Subject: Re: [-Wconversion] incorrect conversion warning for function taking a short On Tue, 27 Apr 2004, falk at debian dot org wrote: > No, the message really means what it says. This warning was designed for people > who also use compilers which do not support prototypes. Nowadays, it is very > unlikely to be useful for anybody; IMHO we might as well remove it. My proposal has been to usurp the option name for "warn for any implicit conversion that may change a value", which would at least have uses (e.g. catching some signed/unsigned security issues); and I don't care much about whether the other existing warnings remain available under -Wconversion-traditional. Implementing this has however never been a priority.
*** Bug 16378 has been marked as a duplicate of this bug. ***
I think we may close this bug report since either: * The solution is to split the functionality of Wconversion as conceived by the Wcoercion project http://gcc.gnu.org/wiki/Wcoercion#Background. In that case, this is a duplicate of bug 9072. * The message is misleading. Maybe it should say: passing arg 1 of 'func' as short instead of 'int' due to prototype. If you agree, I can generate a patch in no time. * This is not a bug. As said in comment 5, Wconversion is meant to warn about conversions that would be different in the absence of prototypes. So we may just close the bug.
See comment #1, this is how it is intended.
*** Bug 29739 has been marked as a duplicate of this bug. ***
*** Bug 38121 has been marked as a duplicate of this bug. ***
*** Bug 38116 has been marked as a duplicate of this bug. ***