---
title: Nonnull argument violation
framework: xcode
role: article
role_heading: Article
path: xcode/nonnull-argument-violation
---

# Nonnull argument violation

Detects when an argument incorrectly receives a null value.

## Overview

Overview Use this check to detect when a function that has an argument with the nonnull attribute or the _Nonnull annotation receives a null value. Available in Xcode 9 and later. note: The nonnull violation check for arguments with the _Nonnull annotation is off by default. You can turn it on by enabling the -fsanitize=nullability-arg compiler flag. Violation of the nonnull parameter attribute in C In the following example, the call to the has_nonnull_argument function breaks the nonnull attribute of the parameter p: void has_nonnull_argument(__attribute__((nonnull)) int *p) {       // ...  } has_nonnull_argument(NULL); // Error: nonnull parameter attribute violation Solution Correct logic errors, or remove the nonnull attribute and rework the called function’s logic accordingly. Violation of the nonnull annotation for an argument in C In the following example, the call to the has_nonnull_argument function breaks the _Nonnull annotation of the parameter p: void has_nonnull_argument(int * _Nonnull p) {       // ...  } has_nonnull_argument(NULL); // Error: _Nonnull annotation violation Solution Correct logic errors, or remove the _Nonnull attribute and rework the called function’s logic accordingly.

## See Also

### Undefined Behavior Sanitizer

- [Misaligned pointer](xcode/misaligned-pointer.md)
- [Invalid Boolean value](xcode/invalid-boolean.md)
- [Out-of-bounds array access](xcode/out-of-bounds-array-access.md)
- [Invalid enumeration value](xcode/invalid-enumeration-value.md)
- [Reaching of unreachable point](xcode/reaching-of-unreachable-point.md)
- [Dynamic type violation](xcode/dynamic-type-violation.md)
- [Invalid float cast](xcode/invalid-float-cast.md)
- [Division by zero](xcode/division-by-zero.md)
- [Nonnull return value violation](xcode/nonnull-return-value-violation.md)
- [Nonnull variable assignment violation](xcode/nonnull-variable-assignment-violation.md)
- [Null reference creation and null pointer dereference](xcode/null-reference-creation-and-null-pointer-dereference.md)
- [Invalid object size](xcode/invalid-object-size.md)
- [Invalid shift](xcode/invalid-shift.md)
- [Integer overflow](xcode/integer-overflow.md)
- [Invalid variable-length array](xcode/invalid-variable-length-array.md)
