On Jan 13, 2011, at 10:21 PM, Nathan Blackham wrote: >>> >>> The warning is this: >>> >>> double d = 42.0; >>> int i = d; // Warning here >> >> Without an explicit cast, shouldn't that be fatal? As you say, it >> isn't. On Ubuntu, even with gcc -Wall, I get no warning. > > I would expect it to be fatal as well. I am surprised that it isn't.
The double is floored to the closest int, unless it's too large to fit. So, yes, it's dangerous. That's why I want the warning on all distros! C++ is too dangerous for the compiler to let this kind of code through without a mention. --Dave /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
