Xcode is Amazing, and Sometimes Quite Confusing

xcode.jpg

OK, today I decided to get the latest Static Analyzer as I have really enjoyed the reports in the past, and I knew from the mailing list I'm on, that there have been a ton of changes. Well... I had no idea.

The first thing was that there were some old plist definitions in the Potentials project and I had to root around to find out where they were defined and then remove the bad names and let the defaults be used. That was slightly frustrating, but I really did enjoy the fact that the navigation of the compile-time parameters has become so easy in Xcode 3 that it's really not that bad a chore.

Once I had that, I needed to make an alias to make it simple to run the analyzer. I added:

  alias checkit '/usr/local/checker/scan-build -k -V xcodebuild
                              -configuration Development

(all on one line) to my .tcshrc and I was ready to hit it again and again. I like that they have incorporated the viewing right off the command-line, very nice.

The next thing I realized was that I was getting a lot of warnings of the form:

  warning: dereferencing type-punned pointer will break strict-aliasing rules

After quite a bit of Googling, I found that it's related to the use of the -fstrict-aliasing optimization option that is put in place (by default) by the -Os optimization (size and speed). So... that's not great. But it shouldn't have been there - so says the Googling. There had to be something else.

And there was... in the GUI if you turn on the "Auto-Vectorization" optimization, then that's the trigger point and there's nothing you can do about it.

Project 201CPotentials201D Info

If you have this checked, then every time you reference super as in:

  if (self = [super init]) {

in your initialization code you're going to get this kind of warning. I tried and tried to use the -Wno-strict-aliasing, but there was nothing I could do to turn off these warnings other than to build as 'Development' (where the optimizations are turned off) or turn off the Auto-vectorization. Shucks.

I read through the man page on gcc and I think the only thing I'm missing out on is the automatic vectorization of loops. It's not to say that it won't be done, but it's going to assume it can't and then see if it can. Not great, but I'm not about to re-write my init methods to skip this, and there's no amount of casting or forcing that removes this error. Calls to super are just not "OK".

I'm not the kind of guy that likes seeing 75 warnings on the build, either. So I have to settle for skipping the auto-vectorization. In the end, I added a few things to the code and cleaned up the build and I'm really rather happy about it. I do believe that Xcode is one of the best development environments that I've ever worked in. It's really quite wonderful.