title: Why uninitialized variable contains garbage instead of ‘nil’?
body: <p>Environment: Mac OS X 10.9, Xcode 5.0.2</p>
  
  <p>I`am create standard Cocoa Application for OS X and disable ARC in project settings. Append one button “Run”:</p>
  
  <p>File “AppDelegate.h”:</p>
  
  <pre><code>#import &lt;Cocoa/Cocoa.h&gt;
  
  @interface AppDelegate : NSObject &lt;NSApplicationDelegate&gt;
  
  @property (assign) IBOutlet NSWindow *window;
  - (IBAction)clickRun:(id)sender;
  
  @end 
  </code></pre>
  
  <p>File “AppDelegate.m”:</p>
  
  <pre><code>#import "AppDelegate.h"
  
  @implementation AppDelegate
  
  - (IBAction)clickRun:(id)sender
  {  
      NSAutoreleasePool* apool = [[NSAutoreleasePool alloc] init];
  
      NSString* pathToFile = @"/Users/admin/1.txt";
  
      NSError* error;
  
      NSLog(@"[1] Retain count of Error: %lx", [error retainCount]);
  
      NSData* dataOfFile = [NSData dataWithContentsOfFile:pathToFile
                                                  options:NSDataReadingMappedIfSafe
                                                    error:&amp;error];
  
      NSLog(@"[2] Retain count of Error: %lx", [error retainCount]);
  
      [apool drain];
  }
  @end
  </code></pre>
  
  <p>When run program and first click button console has output:</p>
  
  <p>“<em>[1] Retain count of Error: 0</em>” – of course zero because variable ‘error’ is uninitialized <br/>
  "<em>[2] Retain count of Error: 0</em>" – second zero tell us what method “dataWithContentsOfFile” is successful read a file.</p>
  
  <p>And debugger all time say what variable ‘error’ has type a ‘nil’.</p>
  
  <p><strong>But</strong> when I second time click button, debugger break on:</p>
  
  <p>NSLog(@"[1] Retain count of Error: %lx", [error retainCount]);</p>
  
  <p>And show message “EXC_BAD_ACCESS” and variable ‘error’ contains garbage and of course [error retainCount] get like segmentation fault. But this vary strange because if method  “dataWithContentsOfFile” successful, it do not allocate variable ‘error’ and no body touch this variable. 
  <br/><br/>
  <strong>From where variable ‘error’ take a garbage and why first click do not contain a garbage?</strong>
  <br/><br/>
  Of course after spend several hours I solve this problem, forced (re)initialization of ‘nil’:</p>
  
  <pre><code>NSError* error = nil;
  </code></pre>
  
  <p>But question above is not expired.</p>