3 ms·
Why _can_ you write &arr[0] in the first place? There is at least some logic behind it (which probably breaks down with multidimensional arrays, a feature that
by jstimpfle 4y ago
Why _can_ you write &arr[0] in the first place? There is at least some logic behind it (which probably breaks down with multidimensional arrays, a feature that probably wasn't there from the start). In C, I suspect that at least in the beginning, there were never arrays on the type and expression level - only pointers.
What security problems are exactly caused by pointer decay?
A similar thing also exists with calls through function pointers, and I do not think you can find many programmers who are willing to write (*foo)(x, y, z) when using function pointers (at least not when there are many, like when using e.g. OpenGL). Or worse, (&foo)(x, y, z) with normal functions.
- pjmlp 4y agoThe usual stuff that array lengths on function declarations are only guidelines, given that they are plain pointers, and when one calculates the array length not taking that into account, somewhere out there there is an happy hacker.