[LLVMbugs] [Bug 10446] New: False positive for dereferencing null pointer (C++ 'this' pointer)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 22 16:17:05 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10446

           Summary: False positive for dereferencing null pointer (C++
                    'this' pointer)
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: piers at ekioh.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6919)
 --> (http://llvm.org/bugs/attachment.cgi?id=6919)
test case

Using downloaded build checker-257, if I assign a variable the contents of
'this', then change that variable as if it were stepping along a linked list, I
get a false positive dereference of a null pointer of 'this'.

The attached test case shows the original code (ifdefed out), plus a simplified
version. Here is a snippet of it, but the attached file is a complete
compilable demonstration. 'this' is never 0.
{
    const A *a = this;
    if (a != 0)
        a = a->m_previous;

    printf("%d", m_variable);
}

/Users/piers/a/test.cpp:31:18: warning: Access to field 'm_variable' results in
      a dereference of a null pointer
    printf("%d", m_variable);
                 ^

(the second warning about an unused variable can be safely ignored and only
exists to keep the case simple)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list