<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 --- - No -Wtautological-pointer-compare warning on variables within parentheses, and the column number might be improved"
   href="http://llvm.org/bugs/show_bug.cgi?id=20951">20951</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>No -Wtautological-pointer-compare warning on variables within parentheses, and the column number might be improved
          </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>Linux
          </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>chengniansun@gmail.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>Clang emits a -Wtautological-pointer-compare on the following expressions,
  NULL == &a,
but does not on the following one
  NULL == (&a)

Moreover, the column of this warning points to the location of the variable a,
but not the location of the comparison expression. Is this deliberate? I find
that a number of Clang warnings point to the operator location. 


========================================================================

$: cat t.c
#include <stdlib.h>
int f(short a) {
  if (NULL == 
             (&a)) { /*no warning here*/
    return 0;
  } else if (NULL ==
              &a) { /*warning here.*/
    return 2;
  } else 
    return 1;
}
$: clang-trunk -Wtautological-pointer-compare -c t.c
t.c:7:16: warning: comparison of address of 'a' equal to a null pointer is
always false [-Wtautological-pointer-compare]
              &a) { /*warning here.*/
               ^
1 warning generated.
$: gcc-trunk -Waddress -c t.c
t.c: In function ‘f’:
t.c:3:12: warning: the comparison will always evaluate as ‘false’ for the
address of ‘a’ will never be NULL [-Waddress]
   if (NULL == 
            ^
t.c:6:19: warning: the comparison will always evaluate as ‘false’ for the
address of ‘a’ will never be NULL [-Waddress]
   } else if (NULL ==
                   ^
$: clang-trunk -v
clang version 3.6.0 (trunk 217725)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Selected multilib: .;@m64
$:</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>