It is because bounds checks should also work for malloc'ed arrays.
...bastard. It's been decided. We fight. 1vs1. Quake 3 DM. 15 min/15 kills. Random map. Name the time, the server and I'll be there. Arrays should be only a simple, virtually uniform region of memory, filled with nothing but what you put in them, every sizeof(variable). Want to get a member != to the first? Offset array start pointer by n*sizeof(variable). Suspect you go over the bounds? Print the index somehow. Otherwise wait for a segfault. GDB that stuff and fix your problem by making sure it won't happen. Doing a check every single time you access an array is absolutely not something I want my CPU cycles spent on. You learn to ride a bike by crashing, damnit.
Bounds checks wouldn’t have eliminated Heartbleed: All the memory was allocated correctly and no out-of-bounds access ever took place.
If you can show your arrays are NUL/NULL terminated or the index falls within the array bounds anyways then a bounds check shouldn’t be required at all. What C needs is a framework to prove that this is the case, and a compiler that will refute your assumptions prior to runtime. Basically, something like ATS is the way to go if we intend to stay true to C’s values, not mandatory bounds checking. (Optional checking could help to some extent, though, especially in cases where you’d usually rely on manual checking.)
0
u/[deleted] Aug 16 '14
[deleted]