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: dcough...@apple.com
          Reporter: manuelm...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to