Xcode seems to be generating bad code
Xcode seems to be generating bad code
- Subject: Xcode seems to be generating bad code
- From: Jeff Laing <email@hidden>
- Date: Thu, 26 Apr 2012 19:43:59 +1000
Clearly, I'm going mad because "I know this used to work".
Sometime in the last day or so, something has changed in my environment such that Xcode 4.3.2 has started generating bad code for my iPad project. It's very easy to reproduce. Create yourself a new empty project, and modify the AppDelegate to contain the following:
int zero;
zero = 0;
if (zero < INT_MIN) {
NSLog(@"Why is 0 < INT_MIN?");
self.window.backgroundColor = [UIColor redColor];
} else {
self.window.backgroundColor = [UIColor whiteColor];
}
When you run this on the simulator, the window will be white.
When you run it on my iPad1, the window is red. Apparently, 0 is smaller than INT_MIN, which is insane.
When I look at the generated assembler fragment, I'm suspicious that it's using a corner case on the Thumb instruction set.
.loc 1 26 2
ldr r0, [sp, #56]
cmn.w r0, #-2147483648
bge LBB1_5
.loc 1 27 3
Ltmp6:
movw r0, :lower16:(L__unnamed_cfstring_-(LPC1_18+4))
movt r0, :upper16:(L__unnamed_cfstring_-(LPC1_18+4))
LPC1_18:
add r0, pc
blx _NSLog
The "cmn.w" apparently compares the negative value - how it managed to store the negative of INT_MIN (which is defined as -(INT_MAX + 1) I don't know.
So, please, someone tell me I've goofed a trivial setting in my project somewhere? I'm suspicious that the code that used to work was in a project that I had *not* upgraded when XCode complained at me - perhaps upgrading to LLVM was what did me in?
When I try to switch my project to use GCC, I get an error about how "-fobjc-arc" is not a valid compiler option - since none of the project settings try to use ARC, I have no idea why it's doing this either.
Thanks in advance,
Jeff.
-------------------------------------------------------------------------------
"... because even if we can't um, if we can't rise to his level, no at least we can, we can drag him down to ours ..."
-- William Gaddis, "JR".
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden