Date: 10 Jun 2002 08:48:24 -0000 Message-ID: <20020610084824.22635.qmail@sources.redhat.com> To: gcc-gnats AT gcc DOT gnu DOT org CC: djgpp-workers AT delorie DOT com Subject: -Wbad-function-cast gives bogus warning for (double) rand() From: richdawe AT bigfoot DOT com X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: djgpp-workers AT delorie DOT com Reply-To: djgpp-workers AT delorie DOT com >Category: c >Synopsis: -Wbad-function-cast gives bogus warning for (double) rand() >Confidential: no >Severity: non-critical >Priority: medium >Class: sw-bug >Submitter-Id: net >Originator: Richard Dawe >Release: gcc 3.1 >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 #include 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 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 AT delorie DOT com and most people think it's a bug. Thank you for your time. Regards, Richard Dawe >How-To-Repeat: >Fix: >Unformatted: