---
title: Out-of-bounds array access
framework: xcode
role: article
role_heading: Article
path: xcode/out-of-bounds-array-access
---

# Out-of-bounds array access

Detects out-of-bounds access of arrays.

## Overview

Overview Use this check to detect attempts to access indexes that exceed the array’s bounds. Out-of-bounds array accesses have undefined behavior, and can result in crashes or incorrect program output. Available in Xcode 9 and later. note: This check doesn’t detect out-of-bounds accesses into heap-allocated arrays. Out-of-bounds array access in C In the following example, out-of-bounds access of array occurs on the last iteration of the loop: int array[5]; for (int i = 0; i <= 5; ++i) {     array[i] += 1; // Error: out-of-bounds access on the last iteration } Solution Ensure that accessed indexes don’t exceed the array’s bounds.

## See Also

### Undefined Behavior Sanitizer

- [Misaligned pointer](xcode/misaligned-pointer.md)
- [Invalid Boolean value](xcode/invalid-boolean.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 argument violation](xcode/nonnull-argument-violation.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)
