There's probably a hole in my C knowledge here, but I'm a little confused as to why this happening.
(lldb) p lineGroup
(NSInteger) $17 = -1
(lldb) p (lineGroup > 4)
(bool) $18 = true
(lldb) p (lineGroup < 0 )
(bool) $19 = false
(lldb) p (-1 < 0)
(bool) $20 = true
(lldb) p ((int)lineGroup < 0 )
(bool) $21 = false
(lldb) p ((int)lineGroup > 4)
(bool) $22 = true
(lldb)
The lineGroup variable is assigned as follows:
- (void)gotLineGroupInformation:(NSString *)lineGroupString
{
NSInteger lineGroup = [lineGroupString integerValue];
if(lineGroup >= 0)
{
// Always gets called
}
else
{
// Never gets called
}
}
Thanks, Andy
The lldb issue seem to be the exact same as in Objective C integer comparison error:
Carl Norum said in his response :
Confirmed - it's a bug in the lldb IR interpreter.
Here's a link to the patch that fixes it: http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20130520/008569.html
Concerning your code, I tried to reproduce the bug without succes with this test:
NSString *lineGroupString = @"-1";
NSInteger lineGroup = [lineGroupString integerValue];
if(lineGroup >= 0)
{
NSLog(@"positive");
}
else
{
NSLog(@"negative"); // This log is correctly called every time
}
Maybe you should try to debug with NSLog for this one (in particular what is the value of lineGroupString right after entering the function ?).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With