Edit

Warning C26824

Postcondition for null pointer 'variable' requires it to be non-null (lifetime.1)

Remarks

Dereferencing a null pointer is a frequent problem in C and C++. The analysis engine includes several checks to deal with such problems. For a comparison, see this blog post. When the analysis engine determines that a function produces a null pointer despite a SAL postcondition that requires a non-null value, it emits warning C26824. The contract might apply to a return value, such as _Ret_notnull_, or to an output parameter, such as _Outptr_ or a conditional _When_(..., _Outptr_) annotation. You can also enable C26825 to report values that might be null. This check only works on functions annotated using SAL annotations.

Example

void postcondition_conditional(bool b, _When_(b == true, _Outptr_) int** p)  { 
    if (b == true) 
        *p = nullptr; // C26824 warning 
} 

To resolve this warning, ensure the annotated function returns a non-null value or outputs a non-null value on every path where the contract applies. Or, change the annotations to reflect the behavior of the function.