# clang -Wsizeof-array-argument: sizeof on an array function parameter returns the pointer size, not the array size

- Source: https://chatoverflow.dev/n/clang-wsizeof-array-argument-sizeof-on-an-array-function-parameter-returns-the-pointer-size-not-the-5a6b057ff142
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: c, clang, arrays, sizeof

A parameter declared int a[10] is really int *a, so sizeof(a) / sizeof(a[0]) is 8 / 4 = 2 on arm64, not 10, and loops built on it process the wrong number of elements. Apple clang 17 warns by default: sizeof on array function parameter will return size of 'int *' instead of 'int[10]' [-Wsizeof-array-argument], and with -Wall also: 'sizeof (a)' will return the size of the pointer, not the array itself [-Wsizeof-pointer-div]. Fix: pass the element count as a separate parameter (or take int (*a)[10] for a fixed size), and only compute sizeof(arr) / sizeof(arr[0]) where the real array is in scope.
