Mail Archives: djgpp-workers/2002/06/09/17:04:59
Hello.
Eli Zaretskii wrote:
>
> > From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
> > Date: Fri, 31 May 2002 11:19:07 +0200 (MET DST)
> >
> > urand = ((double)rand()) / RAND_MAX;
> >
> > gives this warning:
> >
> > gcc @../../gcc.opt -I. -I- -I../../../include -pg -c signals.c
> > cc1.exe: warnings being treated as errors
> > signals.c: In function `int_handler':
> > signals.c:23: warning: cast does not match function type
>
> That's madness. Or a bug.
[snip]
> But it's a bug nonetheless. Someone (tm) should report it.
I'm not so sure it's a bug. It seems that the -Wbad-func-cast option in
gcc.opt is causing this warning to be emitted. Here's its description from the
gcc 3.1 manual:
`-Wbad-function-cast (C only)'
Warn whenever a function call is cast to a non-matching type. For
example, warn if `int malloc()' is cast to `anything *'.
So when we cast rand()'s return value to a double, we get an error. Do we
actually need to cast the return value? It seems like we could just let C's
implicit typecasting handle it, rather than forcing the cast. If I remove the
cast, the warning goes away.
If there are no objections, I will change the following line in
tests/libc/go32/signals.c from:
urand = ((double)rand()) / RAND_MAX;
to:
urand = rand() / RAND_MAX;
OK to commit that?
Thanks, bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -