<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 --- - Comparison against functions is almost always erroneous, should warn"
   href="http://llvm.org/bugs/show_bug.cgi?id=17900">17900</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Comparison against functions is almost always erroneous, should warn
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>oneill+llvmbugs@cs.hmc.edu
          </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>Consider this code:

#include <strings.h>

int indx;

int isIndxZero()
{
    return index == 0;
}

Here the user has mistakenly written “indx” as “index“, which happens to be a
POSIX.1  function. In this comparison, index decays to a pointer-to-function,
is then compared to zero, which becomes interpreted as the null pointer
constant.

As the address of a callable function, index would *never* be null, so at the
very least, this is a comparison that is likely always false. 

It would be nice if at the very least we could warn that the comparison is
false, or better yet, warn about comparing a function with an integer.

Also, if as a result we ended up warning for &indx == 0, that'd be great too,
since that too is always false.</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>