<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 --- - The static analyzer does not understand that CFSTR is never NULL"
   href="http://llvm.org/bugs/show_bug.cgi?id=15270">15270</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The static analyzer does not understand that CFSTR is never NULL
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>peter@stairways.com.au
          </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>This code reports an issue with value potentially being NULL, but if CFSTR is
known to not be NULL, then that assert makes it is clear result cannot be NULL
in this case.

Ironically, it is the assert testing for result != NULL that sets off the
analyzer in this case, but if the analyzer knew that CFSTR was never NULL, then
it would have no difficulty determining that result was never NULL in this
case.

inline void
CFDictionaryGet( CFStringRef def, CFStringRef& result )
{
    result = def;
    assert( (result != NULL) || (def == NULL) ); // Clearly indicates that
result cannot be NULL if def is not NULL
}


void Test2()
{
    CFStringRef value;
    CFDictionaryGet( CFSTR("Variable"), value );
    CFRetain( value ); // Erroneously detects as value might be NULL
}</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>