public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/6980: -Wbad-function-cast gives bogus warning for (double) rand()
@ 2003-03-07 2:42 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-03-07 2:42 UTC (permalink / raw)
To: djgpp-workers, gcc-bugs, gcc-prs, nobody, richdawe
Synopsis: -Wbad-function-cast gives bogus warning for (double) rand()
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 7 02:42:19 2003
State-Changed-Why:
Correct. Testcase:
-------------------
int foo();
void bar () {
(double) foo();
}
-----------------------
Output is bogus:
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -Wbad-function-cast -c x.c
x.c: In function `bar':
x.c:3: warning: cast does not match function type
This is gccs behavior since seemingly forever.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6980
^ permalink raw reply [flat|nested] 2+ messages in thread
* c/6980: -Wbad-function-cast gives bogus warning for (double) rand()
@ 2002-06-10 1:56 richdawe
0 siblings, 0 replies; 2+ messages in thread
From: richdawe @ 2002-06-10 1:56 UTC (permalink / raw)
To: gcc-gnats; +Cc: djgpp-workers
>Number: 6980
>Category: c
>Synopsis: -Wbad-function-cast gives bogus warning for (double) rand()
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 10 01:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Richard Dawe
>Release: gcc 3.1
>Organization:
>Environment:
DJGPP ports of gcc 3.1 & binutils 2.11.2, DJGPP CVS, running on Windows 98 SE
>Description:
Here is a simple test case:
---Start program---
#include <limits.h>
#include <stdlib.h>
int
main (void)
{
double d;
d = (double) rand() / RAND_MAX;
return(EXIT_SUCCESS);
}
---End program---
I compile the program like this and get the following warnings:
bash-2.04$ gcc -Wall -Wbad-function-cast -c a.c
a.c: In function `main':
a.c:9: warning: cast does not match function type
rand is defined in <stdlib.h> like this:
int rand(void);
Since an integer can fit into a double, I don't understand why this code gives a warning. We've discussed the warning on djgpp-workers@delorie.com and most people think it's a bug.
Thank you for your time. Regards, Richard Dawe
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-07 2:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-07 2:42 c/6980: -Wbad-function-cast gives bogus warning for (double) rand() bangerth
-- strict thread matches above, loose matches on Subject: below --
2002-06-10 1:56 richdawe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).