4 ms·
I mean, the whole point of C is for it to be used by people who "know what they're doing" and just won't write code that dereferences invalid pointers (dangling
by trealira 2y ago
I mean, the whole point of C is for it to be used by people who "know what they're doing" and just won't write code that dereferences invalid pointers (dangling pointers, null pointers, pointers that write past arrays, writes to read-only memory, uses of unaligned pointers on platforma where that causes a bus error, etc.) or divides by zero. That way, you get the maximum theoretical performance and flexibility without writing the assembly yourself, assuming you make no such mistakes. It's supposed to be a thin wrapper over the hardware.
If you want a language that does these compile-time and runtime checks on pointers and integers, but is otherwise like C (in that it compiles natively and doesn't use garbage collection), your choices are basically Rust and Ada.