Red Hat Bugzilla – Bug 37482
gcc -Wconversion gives weird conversion warning
Last modified: 2007-04-18 12:32:50 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.2.16-22smp i686)
I think the following program should compile with no warnings:
float foo(float x)
float y = 0.0f;
y = foo(y);
gcc -g -Wall -Wconversion foo.c
foo.c: In function `main':
foo.c:10: warning: passing arg 1 of `foo' as `float' rather than `double'
due to prototype
Steps to Reproduce:
Just compile the above program with -Wconversion.
Actual Results: gcc gives that weird warning.
Expected Results: Since there is no double in the program, I would expect
program to compile without warnings.
That warning is correct:
Warn if a prototype causes a type conversion that is different
from what would happen to the same argument in the absence of a
If you had no prototype and foo was defined elsewhere, main would pass it
a double not a float (that's what default argument promotion rules say), so
you get the warning.