|
|
|
|
|
by rom-antics
1203 days ago
|
|
From the same section, - Any memory access must be done through a pointer value associated with an address range of the memory access, otherwise the behavior is undefined. - A null pointer in the default address-space is associated with no address. A null pointer (0x0) is associated with no address, therefore it has no address range. So if you do attempt a memory access (dereference), the behavior is undefined. QED. A naive translation to assembly would indeed segfault on a modern OS, but LLVM's optimizations are free to assume that code path is unreachable and do anything else. Once the program is in this state, a bug of some kind is unavoidable. I don't take issue with that - what I take issue with is your claim that this behavior is well-defined, because it definitely is not. It would be equally valid for a null dereference to corrupt your program state or wipe your hard disk. |
|