www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/06/09/17:04:59

Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3D03BEF4.78F989@phekda.freeserve.co.uk>
Date: Sun, 09 Jun 2002 21:47:48 +0100
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Patches for building with gcc 3.1 - tests chunk
References: <200205310919 DOT LAA13003 AT lws256 DOT lu DOT erisoft DOT se> <7443-Fri31May2002130616+0300-eliz AT is DOT elta DOT co DOT il>
Reply-To: djgpp-workers AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019