[llvm-bugs] [Bug 39802] New: alpha.deadcode.UnreachableCode false positive when asserting on a float

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 26 22:07:27 PST 2018


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

            Bug ID: 39802
           Summary: alpha.deadcode.UnreachableCode false positive when
                    asserting on a float
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: riku.dev at riksteri.eu
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

Created attachment 21164
  --> https://bugs.llvm.org/attachment.cgi?id=21164&action=edit
unreachable-repro.cpp

The attached sample code produces an analyzer warning about unreachable code
inside the nested for-loops (sample also inlined below). The warning is clearly
a false positive, since I can see the output of the "unreachable" code when I
execute the original, non-minimal application that reproduces this warning.

Command:
clang --analyze -Xanalyzer -analyzer-checker=alpha.deadcode.UnreachableCode
unreachable-repro.cpp

Output:
unreachable-repro.cpp:11:4: warning: This statement is never executed
                        continue;
                        ^~~~~~~~

The warning still occurs if the "continue" is replaced with actually useful
code. The "continue" was the simplest statement I could come up with here.

If the assert is removed or split into two like this:

        assert(0.f <= input);
        assert(input <= 1.f);

then the warning does not appear.
If one or both of the two loops are removed, the warning does not appear.
If the function argument is an integer instead of a floating point type, the
warning does not appear.

I am using the pre-built 64-bit Windows binaries. This occurs at least in
release build version 7.0.0 and snapshot builds 6.0.0-r320423 and
8.0.0-r346630.


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

#include <assert.h>

void unreachable_repro(float input)
{
        assert(0.f <= input && input <= 1.f);

        for(int i = 0; i < 1; ++i)
        {
                for(int k = 0; k < 1; ++k)
                {
                        continue;
                }
        }
}

-- 
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/20181127/524d6d18/attachment.html>


More information about the llvm-bugs mailing list