<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Clang-tidy: expression with calls to a non-pure function is considered as always-true"
   href="https://bugs.llvm.org/show_bug.cgi?id=36505">36505</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang-tidy: expression with calls to a non-pure function is considered as always-true
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>5.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pavel.kryukov@phystech.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19951" name="attach_19951" title="Example of always-true false positive with calls to a non-pure function">attachment 19951</a> <a href="attachment.cgi?id=19951&action=edit" title="Example of always-true false positive with calls to a non-pure function">[details]</a></span>
Example of always-true false positive with calls to a non-pure function

Clang-Tidy produces a false positive warning about always-true expression
(misc-redundant-expression check) if expression contains consequent calls to a
non-pure function which have different return values:

$> clang-tidy -checks='*' ldfile.c -- -Wall
15 warnings generated.
./ldfile.c:11:32: warning: logical expression is always true
[misc-redundant-expression]
    if ((token = yylex()) != 1 || (token = yylex()) != 2) {
                               ^
Suppressed 14 warnings (14 in non-user code).

$> clang ldfile.c -Wall -Wextra && ./a.out
false

The code is taken from GNU Binutils (/ld/ldfile.c) source file.</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>