sizeof when used as a default argument to get the size of an array should always return a size of an array, never the size of a cell. You can pass offsets in to arrays with arr[n] and the compiler correctly compiles that as passing an array offset to index n, but the sizeof seems to do sizeof (arr[n]) instead of sizeof (arr) - n. This is counter-intuitive as the sizeof is applied to the destination parameter, which is declared as an array, not the passed data, which could be anything.
Issue description:
sizeof
when used as a default argument to get the size of an array should always return a size of an array, never the size of a cell. You can pass offsets in to arrays witharr[n]
and the compiler correctly compiles that as passing an array offset to indexn
, but the sizeof seems to dosizeof (arr[n])
instead ofsizeof (arr) - n
. This is counter-intuitive as thesizeof
is applied to the destination parameter, which is declared as an array, not the passed data, which could be anything.Minimal complete verifiable example (MCVE):
This prints:
I'd expect:
Or at the very least:
But that can lead to OOBs.
Workspace Information: