<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - uninitialized __block storage variables used in blocks don't provoke warning"
   href="http://llvm.org/bugs/show_bug.cgi?id=15725">15725</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>uninitialized __block storage variables used in blocks don't provoke warning
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tjw@me.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10337" name="attach_10337" title="test case">attachment 10337</a> <a href="attachment.cgi?id=10337&action=edit" title="test case">[details]</a></span>
test case

See the attached test case, in which a __block variable is left uninitialized
and then used w/in a block:


void test0(void)
{
    __block int x; // BAD: No warning that this is the uninitialized variable

    void (^block)(void) = ^{ // BAD: No warning that an uninitialized variable
is captured
        printf("x = %d\n", x);
    };
    block();
}

This is conceivably good in the case that the block variable is out-only (the
block initializes it), but a very common pattern with Foundation is now:

__block BOOL success = NO;
__block NSError *error;
[coordinator coordinate... ^(NSURL *newURL){
   ... do a bunch of stuff that might fail ...
   success = YES;
}];
if (!success) {
  ... handle the error ...
}

In the case that you forget the 'NO' initializer above, you'll miss your error
handling case with disastrous results.

This is especially insidious in ARC mode where you get trained to not
initialize locals (since ARC initializes object pointer locals to nil for you).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>