iPhone original and iPhone 3G use the armv6 architecture, later models armv7. An answer to this Stack Overflow question, and an Apple developer forum thread point to a problem in the armv6 Thumb code produced by XCode 4.2's compiler which cause arithmetic on certain data structures, in particularCGPoint
, to return completely wrong results. Such as the x value being written into the y value.
The solution is to add the -mno-thumb
compiler option to the XCode project. This tells the compiler not to emit Thumb mode code, thereby bypassing the bug. Another solution is to switch back to an earlier XCode (pre-iOS5 SDK), which doesn't have this bug.
So the bug is in the compiler! How cool is that? :) In two decades of developing, I was yet to come across such a thing.
Here's a screenshot showing where to add this compiler option if it helps anyone: