title: EXC_BAD_ACCESS on very simple Objective-C program (Snow Leopard)
body: <p>I'm following through one of the very early examples in <a href="https://rads.stackoverflow.com/amzn/click/com/1430218150" rel="nofollow noreferrer" rel="nofollow noreferrer" title="Learning Objective-C on the Mac">Learning Objective-C on the Mac</a>. My code is almost exactly the same as the code in the book (a couple spaces and trivial parentheses may differ). It looks like this:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  BOOL areIntsDifferent (int thing1, int thing2) {
      if (thing1 == thing2) {
          return NO;
      }
      else {
          return YES;
      }
  
  }
  
  NSString * boolString (BOOL yesNo) {
      if (yesNo == NO) {
          return (@"NO");
      }
      else {
          return (@"YES");
      }
  }
  
  
  int main (int argc, const char * argv[]) {
      BOOL areTheyDifferent;
  
      areTheyDifferent = areIntsDifferent(5, 5);
      NSLog(@"are %d and %d different? %@", 5, 5, boolString(areTheyDifferent));
  
      areTheyDifferent = areIntsDifferent(23, 42);
      NSLog(@"are %d and $d different? %@", 23, 42, boolString(areTheyDifferent));
  
      return 0;
  }
  </code></pre>
  
  <p>When I run the code, this is what I get in the console:</p>
  
  <pre><code>[Session started at 2009-12-19 01:41:37 -0500.]
  GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
  Copyright 2004 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys001
  Loading program into debugger…
  Program loaded.
  run
  [Switching to process 3125]
  Running…
  2009-12-19 01:41:38.432 BOOL Party[3125:a0f] are 5 and 5 different? NO
  Program received signal:  “EXC_BAD_ACCESS”.
  sharedlibrary apply-load-rules all
  </code></pre>
  
  <p>I'm not sure why this is happening. I do know that it has something to do with the <code>boolString</code> function, because when I comment out the call to it, the program runs fine. My gut tells me that this has something to do with some new memory management stuff in Snow Leopard (this book predates Snow Leopard by about six months). Anyone know what the problem might be?</p>