3 ms·
There is the classic case of the Linux kernel dereferencing a null point and then check if it is null. Then the compiler removed the null pointer check because
by phicoh 3y ago
There is the classic case of the Linux kernel dereferencing a null point and then check if it is null. Then the compiler removed the null pointer check because dereferencing a pointer means that it cannot be null without invoking undefined behavior.
This is just horrible. C started out as portable assembler. Now essential instructions get deleted. The C standard is a horrible way to define a low-level programming language. Obviously, C is a sharp object. But standard C is a sharp object that jumps at you.
I had a lot of fun writing C. The same way you can have fun writing assembler or do other level stuff. Compared to low-level kernel stuff, C is not a big problem.
I'm talking radically different architectures. Virtual memory has a high cost in the implementation of a CPU. There could be other architectures, capability based, segment based, etc. But if your CPU has to run C efficiently, then you probably don't want to go there.
There is a lot of cruft, like ASLR, that only exists because memory is a flat array of bytes.
As long as the primary goal of a CPU is to run C efficiently, we won't get beyond paged virtual memory.