Message-ID: <3CF7578A.2C2ADFE1@yahoo.com> Date: Fri, 31 May 2002 06:59:22 -0400 From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Martin Stromberg wrote: > > Richard's mail dated Sun, 26 May 2002 17:00:53 +0100: > tests/libc/go32/signals.c: The following line: > > 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 > ... snip ... > > But, surely this is another useless one. When did casting from int to > double become a non-matching type? C is defined to convert integer > types to floating point types if the expression contains a mix. (An > assignment is an expression.) In this case we explicitly want to > convert to double. How to do that? Umm... Let's see... Perhaps we > should cast it?! It converts a double expression to int (if urand is integral). I think you have a valid complaint about the actual warning text, but the assignment is losing information. Once more, in general I would prefer to be warned. So I think the solution here IS to cast the result. We really don't want the fractional part :-) -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net) Available for consulting/temporary embedded and systems. USE worldnet address!