[cfe-commits] r76911 - /cfe/trunk/lib/Analysis/CFG.cpp

Ted Kremenek kremenek at apple.com
Fri Jul 24 11:12:49 PDT 2009


On Jul 24, 2009, at 10:52 AM, Mike Stump wrote:

> On Jul 23, 2009, at 9:19 PM, Ted Kremenek wrote:
>> This looks a little suspicious to me.  Doesn't '-1' convert to  
>> 'true' when an int is casted to a bool?  This would cause 'KnowVal  
>> == true' to evaluate to true even when 'KnownVal' is -1.
>
> I think everyone else covered this already, but yes, (bool)-1  
> converts to true, but that doesn't cause 'KnowVal == true' to  
> evaluate to true even when 'KnownVal' is -1 as KnownVal isn't bool.   
> -1 Converts to -1, when converted to an int, and true, when  
> converted to an int converts as 1, and -1 != 1.
>

Yeah I got it.  Thanks Mike!  Your code was correct, although I still  
prefer the use of a variant as it makes it less error prone with  
future changes to the code.  It also makes the algorithm more clear.



More information about the cfe-commits mailing list