<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 --- - Undetected use of uninitialised variable (detected at -O2 -Wall by gcc)"
   href="http://llvm.org/bugs/show_bug.cgi?id=17940">17940</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Undetected use of uninitialised variable (detected at -O2 -Wall by gcc)
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.3
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>christophe@taodyne.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=11543" name="attach_11543" title="Source code example">attachment 11543</a> <a href="attachment.cgi?id=11543&action=edit" title="Source code example">[details]</a></span>
Source code example

At -O2 or above, GCC 4.2 detects that the 'result' variable can be used
uninitialised in the attached code. clang 3.3svn (as shipped with OSX) does
not.

Compile with "true" g++ -O2 -Wall:

g++ -Wall -O2 -c /tmp/glop.cpp                                                  
/tmp/glop.cpp: In function 'char* undetected()':                                
/tmp/glop.cpp:6: warning: 'result' may be used uninitialized in this function 

With llvm-g++, there is no message.

Reduced test case:

extern bool dont_stop();
extern char *data(unsigned);

char *undetected()
{
    char *result;
    for (unsigned count = 0; count < 2 && dont_stop(); count++)
        result = data(count);
    return result;
}</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>