Nonnull variable assignment violation
Detects when you incorrectly assign null to a variable.
Overview
Use this check to detect when you assign null to a variable with the _Nonnull annotation. Available in Xcode 9 and later.
Violation of nonnull annotation with variable assignment in C
In the following example, the call to assigns_a_value breaks the _Nonnull annotation of the variable q:
void assigns_a_value(int *p) {
int *_Nonnull q = p; // Warning: null can be assigned
}
assigns_a_value(NULL); // Error: _Nonnull variable violationSolution
Correct logic errors, or remove the _Nonnull annotation.
See Also
Undefined Behavior Sanitizer
Misaligned pointerInvalid Boolean valueOut-of-bounds array accessInvalid enumeration valueReaching of unreachable pointDynamic type violationInvalid float castDivision by zeroNonnull argument violationNonnull return value violationNull reference creation and null pointer dereferenceInvalid object sizeInvalid shiftInteger overflowInvalid variable-length array