top | item 41021669

(no title)

blirio | 1 year ago

Oh wait, I just remembered null is normally 0 in C and C++. So probably not that if it is not 0.

discuss

order

cmpxchg8b|1 year ago

If you have a page mapped at address 0, accessing address 0 is valid.

chongli|1 year ago

NULL isn't always the integer 0 in C. It's implementation-defined.

loeg|1 year ago

In every real world implementation anyone cares about, it's zero. Also I believe it is defined to compare equal to zero in the standard, but don't quote me on that.

taspeotis|1 year ago

What? If you have a null pointer to a class, and try to reference the member that starts 156 bytes from the start of the class, you’ll deference 0x9c (0 + 156)

emmelaich|1 year ago

Strangely, not necessarily on every implementation on every processor.

It's not guaranteed that NULL is 0.

Still, I don't think you'd find a counterexample in the wild these days.