-Wconversion producing incorrect warning

Segher Boessenkool segher@kernel.crashing.org
Fri Nov 4 11:54:00 GMT 2005


> using GCC 3.3.5, 3.4.3 and 4.0.1 with '-Wconversion' in effect, I get 
> this warning:
>
> luigi.c: In function `main':
> luigi.c:15: warning: passing arg 1 of `f' with different width due to 
> prototype
>
> I don't understand why this is true... the prototype and the argument 
> are of the same type.

Yes, so the parameter will be passed as whatever your ABI
specifies for parameters of unsigned 16-bit type.

The problem here is, that -Wconversion does _not_ warn
about type conversions in your code!  It is a warning for
people trying to port old K&R C code to ANSI C.  What the
warning means is, "if there would not have been a prototype
for f() in scope, the parameter would have been passed as
a 32-bit type".

GCC does not currently have a warning with the behaviour
you might have expected, and the name of "-Wconversion"
confuses a lot of people.  Perhaps we should change its
name...


Segher



More information about the Gcc-help mailing list