From: rpolzer AT web DOT de (Rudolf Polzer) Newsgroups: comp.os.msdos.djgpp Subject: Re: Windows ME and DJGPP References: <3a78130f DOT 16030234 AT news DOT freeserve DOT net> X-newsgroup: comp.os.msdos.djgpp X-Mailer: GehtDichNenScheissdreckAn 1.0 User-Agent: GehtDichNenScheissdreckAn 1.0 Message-ID: User-Agent: slrn/0.9.6.2 (Linux) Date: Thu, 1 Feb 2001 17:53:50 +0100 Lines: 47 NNTP-Posting-Host: 213.7.23.119 X-Trace: 981046055 news.freenet.de 23436 213.7.23.119 X-Complaints-To: abuse AT freenet DOT de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Jason Green schrieb Folgendes: > 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); And what about unsigned int? static_cast (f)? I hate C-style casts because I do not know what they do; they are a mixture of static_cast and reinterpret_cast. So I do not like (unsigned int) f . > This would surely cause problems when using a severe set of warnings, > but everyone aims to get a clean compile with -Wall, right? ;-) ACK. They are _warnings_ and not _errors_. Why not suggest to the gcc maintainers that gcc should print x.cpp:3 warning: instantiated from here or x.cpp:3 error: instantiated from here instead of x.cpp:3 instantiated from here ? The RHIDE problem would go away immediately. -- Nuper erat medicus, nunc est vispillo, Diaulus: Quod vispillo facit, fecerat et medicus.