3 ms·
"Unlike higher-level languages, the C standard does not define any checks that could detect such erroneous accesses ["buffer overflows, NULL pointer dereference
by mcguire 9y ago
"Unlike higher-level
languages, the C standard does not define any checks that
could detect such erroneous accesses ["buffer overflows,
NULL
pointer dereferences, and
use-after-free errors"] and then abort the program."
Stephen Kell, in "Some Were Meant for C: The Endurance of an Unmanageable Language", writes a simple and fairly strong argument that, for C, that's not a valid complaint. Since C is a systems language, the proper place to look for those (particularly runtime) checks is in the combination of the C standard and the system it's running on, particularly the hardware.
Edit: "Compiler optimizations can lead to
false positives
. For example, a false positive that was found in an ASan-instrumented
Firefox build was caused by load-widening [55] where a series of loads is transformed into a single load of several memory values at once while potentially exceeding the bounds of
an object. Due to platform-specific alignment requirements,
such an optimization can be correct at the system level; however, ASan classified it as a bug because the access would
be out of bounds in C."
Yep, there we go.
- pjmlp 9y agoSystems languages looked quite different in what it meant to be unsafe before C took the keys of the kingdom.
- girvo 9y agoRight. I think a lot of people forget that C wasn’t (and isn’t!) the only systems language that was in heavy usage, and indeed a lot of its predecessors and contemporaries were much safer. But hey, worse is better, and C won, so I’m fighting a losing battle here I think.
- rurban 9y ago> "Unlike higher-level languages, the C standard does not define any checks that could detect such erroneous accesses ["buffer overflows, NULL pointer dereferences, and use-after-free errors"] and then abort the program." Actually C11 Annex K does. It's just that it is ignored because it came from Microsoft.