[llvm-bugs] [Bug 36685] New: Possible false positive: takes branches that contradict each other

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 11 05:11:59 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=36685

            Bug ID: 36685
           Summary: Possible false positive: takes branches that
                    contradict each other
           Product: clang
           Version: 6.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: manuelmohr at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20048
  --> https://bugs.llvm.org/attachment.cgi?id=20048&action=edit
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] http://ndevilla.free.fr/median/median.pdf

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180311/5bcc51bf/attachment.html>


More information about the llvm-bugs mailing list