Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
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.