From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: Windows ME and DJGPP Date: Wed, 31 Jan 2001 22:58:56 +0000 Organization: Customer of Energis Squared Lines: 48 Message-ID: References: <3a78130f DOT 16030234 AT news DOT freeserve DOT net> NNTP-Posting-Host: modem-206.cesium.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: newsg1.svr.pol.co.uk 980981944 24821 62.136.46.206 (31 Jan 2001 22:59:04 GMT) NNTP-Posting-Date: 31 Jan 2001 22:59:04 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com dontmailme AT iname DOT com (Steamer) wrote: > Eli Zaretskii wrote: > > Hmm? Is this in C or in C++? I don't think you need any casts in a C > > program for assigning int to a double or the other way around. > > Nor do you in C++. It's strange that GCC chooses to warn about > this in C++ but not in C. Even stranger when you consider that it does so without even *any* -W... switches. Unless, that is, you are of the opinion that this is an "obviously dangerous conversion" - [BS; CPL3]. Apart from the obvious problem that the value will be truncated to an integer, there is also undefined behaviour when the integer value is outside the range of an int. Of course, an explicit conversion says to gcc: Yes! I really wanted to do that, and the warning goes away: float f = 1.2; int i = int(f); > > > Compiling: x.cpp > > > In function `double intconv(double>': > > > x.cpp (9) Error: instantiated from here > > (Of course, this isn't an error, it's just a RHIDE misinterpretation > of a warning message, which was what Rudolf Polzer was pointing out. > I thought this was fixed in newer versions of RHIDE.) This would surely cause problems when using a severe set of warnings, but everyone aims to get a clean compile with -Wall, right? ;-) > > > x.cpp (3) Warning: initialization to `int' from `double' > > > > If you don't like strongly typed languages, don't use C++. And if you do like strongly typed languages, don't use C. ;-) > Some people consider C++ to be a weakly typed language. > It depends on your perspective... > > In any case, C++ is only slightly more strongly typed than C, > and there is no difference at all as far as initializing an int > with a double is concerned. I guess gcc and g++ view implicit conversions from a different perspective.