Bug 37482 - gcc -Wconversion gives weird conversion warning
Summary: gcc -Wconversion gives weird conversion warning
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-04-24 21:49 UTC by Wagner T. Correa
Modified: 2007-04-18 16:32 UTC (History)
1 user (show)

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


Attachments (Terms of Use)

Description Wagner T. Correa 2001-04-24 21:49:52 UTC
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 11:33:49 UTC
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.