Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
According to the C++ standard, the value of 'this' is never null; some compilers will optimize this check out
Remarks
While MSVC doesn't do such optimizations, some compilers optimize null checks for this out. Code that relies on null-valued this can trigger unexpected behavior when compiled with other compilers. This warning helps detect these portability problems.
Code analysis name: NO_NULLCHECK_FOR_THIS
Example
The following example generates C6390:
struct X
{
void m()
{
if(!this) // Warning: According to the C++ standard, the value of 'this' is never null; some compilers will optimize this check out
return;
}
};
To solve this problem, rewrite the code to never call non-static member functions on null pointers.