shankha via llvm-dev
2016-May-22 17:16 UTC
[llvm-dev] Using clang to recognize illegal reference acceess
I was going through the the presentation by Herb Sutter presentation (https://github.com/isocpp/CppCoreGuidelines/blob/master/talks/Sutter%20-%20CppCon%202015%20day%202%20plenary%20.pdf) Slide No : 21. The code: class A { public: void foo() const; }; void A::foo() const {} std::unique_ptr<A> foo2() { std::unique_ptr<A> pa(new A()); return pa; } void foo() { const A& ra = *foo2(); // Incorrect ra.foo(); } 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. Thanks