3 ms·
Passing 0 as the index into an indexing operation is not even remotely "accessing a null value". Also, believe it or not, on various machines and OS's it's leg
by eridius 13y ago
Passing 0 as the index into an indexing operation is not even remotely "accessing a null value".
Also, believe it or not, on various machines and OS's it's legal to map address 0.
Edit: Your edit makes even less sense. There is no such thing as a "null index", much less an operation to "access a null index".
- Dylan16807 13y ago>There is no such thing as a "null index", Would you rather I write "index that is 0 in a world where indexes start at 1" over and over? I am willing to do that if it helps make the conversation smoother. >much less an operation to "access a null index". foo_array[0]; //operation to do an access with a null index >Also, believe it or not, on various machines and OS's it's legal to map address 0. Which is a bad thing. You get a couple extra variable slots in exchange for thousands of privilege-escalation bugs that could instead be crash bugs.
- lectrick 13y agoHow in the hell does "accidentally" accessing the first element of an array (by "accidentally" passing 0 to an array in a language that has 0-based indexing) result in "privilege escalation errors"? That's just "shitty programming". For that matter, how does a 1-based indexing language NOT result in far more "off by one" errors which would include the kind of errors commonly known as "buffer overflow" errors?
- Dylan16807 13y agoIn most cases indexing doesn't affect safety, the privilege stuff was related to what eridius was talking about with physical addresses. I don't think either one creates more off-by-one errors in people used to it.