Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

False positive for dereferencing null pointer (C++ 'this' pointer) #10715

Open Quuxplusone opened 13 years ago

Quuxplusone commented 13 years ago
Bugzilla Link PR10446
Status NEW
Importance P normal
Reported by piers@ekioh.com
Reported on 2011-07-22 18:17:04 -0700
Last modified on 2011-07-22 18:19:07 -0700
Version unspecified
Hardware Macintosh MacOS X
CC llvm-bugs@lists.llvm.org, piers@ekioh.com
Fixed by commit(s)
Attachments test.cpp (377 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 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)
Quuxplusone commented 13 years ago

Attached test.cpp (377 bytes, application/octet-stream): test case