I am learning SAL Annotations, I tested this example in Visual Studio 2017.
I thought the compiler will report warning or error when I pass a NULL pointer to InCallee
, however, it still can build correctly.so my question is whether SAL is just like code comments and won't validate legality of the data, or it can check the data, just because I made something wrong?
void InCallee(_In_ int *pInt) //_In_ is allowed to be NULL
{
int i = *pInt;
}
void GoodInCaller()
{
int *pInt = new int;
*pInt = 5;
InCallee(pInt);
delete pInt;
}
void BadInCaller()
{
int *pInt = NULL;
InCallee(pInt); // pInt should not be NULL
}