[llvm-bugs] [Bug 42815] New: static analyzer false positive: non-null value is believed to be null [clang-analyzer-core.uninitialized.UndefReturn]

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 29 12:14:42 PDT 2019


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

            Bug ID: 42815
           Summary: static analyzer false positive: non-null value is
                    believed to be null
                    [clang-analyzer-core.uninitialized.UndefReturn]
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: raffael at casagrande.ch
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

Overview:
Under some circumstances, the static analyer believes that a null reference is
being returned when it is clearly not. 

Steps to Reproduce
1) run scan-build g++ main.cc


Actual Results:

In file included from main.cc:1:
In file included from ./Eigen/Eigen:2:
In file included from ./Eigen/Sparse:26:
In file included from ./Eigen/SparseCore:39:
./Eigen/src/SparseCore/CompressedStorage.h:121:80: warning: Returning null
reference
    inline StorageIndex& index(Index i) { eigen_internal_assert(m_indices!=0);
return m_indices[i]; }
                                                                              
^~~~~~~~~~~~~~~~~~~
1 warning generated.
scan-build: 1 bug found.


Expected Results:
No bug should be found.


Build information:
The bug appears on the latest trunk build (git hash
89fb9e8ce151d48b56a6bc25de62e93743e0d6c1), pulled on July 29th 2019. The bug
was first encountered on clang-tidy-8.


Additional Information:

- The attached example code illustrates the issue. I've reduced it as much as
possible, but I couldn't get rid of the Eigen dependency in reasonable time,
therefore I've just included it.
- By uncommenting line 18 in main.cc the warning disappears, but this is of
course not practical.

-- 
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/20190729/8e2205cd/attachment.html>


More information about the llvm-bugs mailing list