When passed to a function, an array decays to a pointer. It loses size information. Inside the function, sizeof(arr) / sizeof(arr[0]) doesn't work because arr is just a pointer now.
Decay happens automatically whenever an array is used where a pointer is expected. Function parameters, pointer assignments, and arithmetic all trigger it. Size information disappears.
This is core C++ behavior from C. The language trades size info for efficiency. A pointer is 8 bytes regardless of array size. But you lose the ability to query size inside functions.