3 ms·
* No NULL pointer can be dereferenced. NULL pointers CAN be dereferenced, it all depends on the environment you run on.
by raarts 10y ago
* No NULL pointer can be dereferenced.
NULL pointers CAN be dereferenced, it all depends on the environment you run on.
- gpderetta 10y agoIn standard C NULL pointers cannot be dereferenced. Full stop, there is nothing to argue about it. There are environments that either lack memory protection and do not allow invalid pointer derereferences to be caught, which means that you can't rely on the MMU to catch mistakes. In this case either deal with silent errors or get a compiler that is able (at a cost) to sanitize any pointer access. There are other systems in which memory address 0 is a perfectly valid address. The ABI of these systems should pick a different bit pattern for NULL pointers, but often don't so compilers sometime offer as a conforming extension extension the option to allow null pointers to be treated as valid (in effect not having null pointers at all).
- mjevans 10y agoThere are indeed such systems. Embedded systems (which are frequently programmed in assembly or 'C' code). Such systems very often map a small bit of high-speed (on chip) RAM to the first few bytes of address space. I very distinctly recall such an embedded system in a college course.