3 ms·
You can't pass an array to a procedure without it becoming a pointer. But that is not even the issue ... the issue is that even if you know something is an arra
by jblow 10y ago
You can't pass an array to a procedure without it becoming a pointer. But that is not even the issue ... the issue is that even if you know something is an array, any pointer of any type could be pointing anywhere into the interior of that array.
- ArkyBeagle 10y agoIf you 1) Know the base address of the array. 2) Know the offset of the element(s) you're passing 2a) Know the declared length ( or other upper limit for the array ). then you need never refer to any element of an array that doesn't exist.
- jblow 10y agoThat's not the problem. The problem is any other live pointer could point into that array, for all the compiler knows. Unless the array was generated locally and never aliased, then if you ever call through some set of procedures that the compiler doesn't have complete visibility into, then it is possible that that code generates a pointer into that array and then uses it. The compiler has to be VERY conservative.