> Date: Mon, 31 Mar 2008 15:18:09 -0700
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: C++0X gets lambdas/closures
>
> Gabriel Sechan wrote:
> >
> > ----------------------------------------
> >> Date: Mon, 31 Mar 2008 13:51:22 -0700
> >> From: [EMAIL PROTECTED]
> >>
> >> If 99% of the time the result is correct, does that make the code right
> >> 99% of the time?
> >>
> >>
> >
> > Rephrasing: 99% of the time, the code in that situation *is* correct.
> > It's only rarely an error. The correct answer is to flag it for human
> > checking, but to allow it, which is what a warning does.
>
> Heh, I was just tweaking you. ;-)
>
> Eliminating the warnings is sometimes pretty tedious!
> I'm in the camp that says it's worth it, even to the point of -Wall.
> I certainly tend to wrinkle my nose when there are lots of warnings.
>
> Would this be correct?
> """
> #include <limits.h>
> ...
> if (libretval_x & INT_MAX < mysigned_x)
> do something..
> """
>
Platform specific- INT_MAX doesn't have to be 011111....1111. It can be all
0's, if the platform is braindead. So that's undecidable without more
knowledge.
This is a case where you'd have to cast one or the other's values to change the
sign. Usually you cast the signed to unsigned, but that's a style thing. Most
compilers take an explicit cast to be always correct, and won't generate a
warning.
Gabe
_________________________________________________________________
Windows Live Hotmail is giving away Zunes.
http://www.windowslive-hotmail.com/ZuneADay/?locale=en-US&ocid=TXT_TAGLM_Mobile_Zune_V3--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg