Bug 37482 - gcc -Wconversion gives weird conversion warning
gcc -Wconversion gives weird conversion warning
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-04-24 17:49 EDT by Wagner T. Correa
Modified: 2007-04-18 12:32 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-04-24 17:49:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Wagner T. Correa 2001-04-24 17:49:52 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)
{
	return (x);
}

int main(void)
{
	float y = 0.0f;

	y = foo(y);
	return 0;
}

But:

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


Reproducible: Always
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
the
program to compile without warnings.
Comment 1 Jakub Jelinek 2001-04-25 07:33:49 EDT
That warning is correct:
`-Wconversion'
     Warn if a prototype causes a type conversion that is different
     from what would happen to the same argument in the absence of a
     prototype.
     ...
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.

Note You need to log in before you can comment on or make changes to this bug.