[llvm-dev] Using clang to recognize illegal reference acceess

shankha via llvm-dev llvm-dev at lists.llvm.org
Sun May 22 10:16:45 PDT 2016

I was going through the the presentation by Herb Sutter presentation

Slide No : 21.

The code:

class A
        void foo() const;

void A::foo() const {}

std::unique_ptr<A> foo2()
    std::unique_ptr<A> pa(new A());
    return pa;

    const A& ra = *foo2(); // Incorrect

clang does not report a error at the following line:
 const A& ra = *foo2(); // Incorrect

I am using the following command line:
 clang++ -std=c++11 --analyze -Xanalyzer -analyzer-output=text
-Xanalyzer -analyzer-checker=core.NullDereference test.cpp
clang version : 3.8

Could you please let me know if I need to pass any other parameters to
clang so that it can recognize this error.


More information about the llvm-dev mailing list