Re:Why do arrays start at 0?
by vukgr on Wednesday August 24, 2022 @04:30PM
(#32585337)
Can't say I've really thought this through, but couldn't you just subtract 1 (*sizeof(X)) from the arr address?
[ Parent
| on HN ]
What would memset(arr, 0, sizeof(arr)) do in that case? I can see myriad problems with having arr itself point outside the memory range allocated to arr[min..max].
Re:Why do arrays start at 0?
by saalweachter on Wednesday August 24, 2022 @04:45PM
(#32585503)
Hmm, maybe?
You'd still have the odd subtract here or there, but for many use patterns you could probably ignore the overhead.