www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/05/31/05:45:46

From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200205310919.LAA13003@lws256.lu.erisoft.se>
Subject: Re: Patches for building with gcc 3.1 - tests chunk
To: djgpp-workers AT delorie DOT com
Date: Fri, 31 May 2002 11:19:07 +0200 (MET DST)
In-Reply-To: <Pine.SUN.3.91.1020530121058.13992A-100000@is> from "Eli Zaretskii" at May 30, 2002 12:11:26 PM
X-Mailer: ELM [version 2.5 PL3]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Eli said:
> What warning is that, exactly?  (I didn't yet install GCC 3.1.)

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

I've looked into it and it's the "-Wbad-function-cast" that triggers it.

So how are you supposed to cast return values from funtions when you
really do want that when this option is on?

Evidently this option is for detecting "p = (sucker_t
*)malloc(sizeof(sucker_t));", which is nice and which I don't disagree
with.

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?! 


Right,

						MartinS

- Raw text -


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