Mail Archives: djgpp-workers/2002/06/10/06:04:54
Hello.
Eli Zaretskii wrote:
>
> On Sun, 9 Jun 2002, Richard Dawe wrote:
>
> > `-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.
>
> Are you saying that int and double do not match? They are both
> arithmetic types, and the number of significant digits supported by a
> double (about 17) is more than enough to represent all 32-bit integers.
I didn't read the description properly - apologies. But removing
-Wbad-function-cast does eliminate the warning. I agree with you now that this
is a bug in gcc 3.1.
> > Do we actually need to cast the return value?
>
> We need it to force the division to be done in floating point (as opposed
> to two integers). But there are other ways of doing that, some of which
> I mentioned in this thread several days ago.
I've posted a new patch, using one of those methods.
Thanks, bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -