Some member functions may be fail-safe in the sense that they check for "this == nullptr" before accessing a member. However, the code analysis apparently does not detect this and keeps warning about dereferencing a NULL pointer.
Is there a SAL annotation to silence this warning at the source location?
I know it is possible to suppress C6011 on the calling sites but this is inconvenient.
Oh and by the way: std::shared_ptr used to throw an exception if the client pointer was NULL and the user attempted to dereference it. Now (VS 2012) it does not throw anymore.
The code below compiles and runs without causing an Access Violation.
#include <tchar.h> struct Foo { int m_x; void Do() { if (this) m_x = 5; } }; int _tmain(int argc, _TCHAR* argv[]) { Foo* f = nullptr; f->Do(); // C6011: Dereferencing NULL pointer 'f'. return 0; }