5 ms·
>> To validate the index, you need two comparisons. If your code doesn't have bugs, no validation of indexes is required.
by phkahler 5y ago
>> To validate the index, you need two comparisons.
If your code doesn't have bugs, no validation of indexes is required.
- cesarb 5y ago> If your code doesn't have bugs, no validation of indexes is required. Your code doesn't have bugs because you validated your indexes. What you said makes some sense when the index comes from within the program itself, but not when it comes from outside the program. Consider for instance the case of reading a data structure from a file or the network, where one field is an index or an offset into another part of the structure; you must validate that this index or offset is not outside the bounds, no matter how perfect your code is.
- kingcharles 5y agoThe number of programs ever written without bugs can be counted in a uint8.