<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 - Possible false positive: takes branches that contradict each other"
   href="https://bugs.llvm.org/show_bug.cgi?id=36685">36685</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Possible false positive: takes branches that contradict each other
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </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>Static Analyzer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>manuelmohr@gmail.com
          </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=20048" name="attach_20048" title="Source code of median search and reduced caller.">attachment 20048</a> <a href="attachment.cgi?id=20048&action=edit" title="Source code of median search and reduced caller.">[details]</a></span>
Source code of median search and reduced caller.

The attached reduced source code implements a fast median computation according
to [1] and contains a placeholder caller.

If the caller passes its input array directly, clang does not report any
problems.
If the caller copies its input array to a local array and then runs the median
computation (compile with "-DCOPY"), clang finds a bug.
I therefore suspect a false positive.

The path it takes assumes the following conditions:

Lines 38--40:
array[1] <= array[2]
array[0] <= array[2]
array[1] <= array[0]

Line 43:
Swapping is a NOP due to middle == low + 1.

Lines 50:
array[0] > array[2]

This contradicts assumption array[0] <= array[2], hence the reported bug should
be impossible and thus a false positive.


[1] <a href="http://ndevilla.free.fr/median/median.pdf">http://ndevilla.free.fr/median/median.pdf</a></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>