bzt wrote:No, not at all. NULL is defined by libc not by the compiler
It is defined by the language standard, actually. But you are mixing up concepts, again. NULL is the name of a macro that is defined in stdlib.h in hosted implementations, that expands to a null pointer constant. A null pointer constant is a constant integer expression with value 0 or such an expression cast to a pointer type. Due to this ambiguity, the NULL macro is pretty much useless, by the way, because any place where the type can be inferred based on context, NULL and 0 are equivalent, and any place where the type cannot be inferred, you need an explicit conversion anyway.
Back to the topic: While the NULL macro is only defined to exist in hosted implementations, null pointers are not so constrained, and are any pointer that compare equal to zero. How your implementation chooses to compare pointers and the integer zero is implementation-defined. Nonetheless, the null pointer is guaranteed to be unequal to the address of any object. Therefore, having an object with a null address is not even undefined, it is breaking the standard.
bzt wrote:Why do you think that? I was speaking about computer memory addresses, which has nothing to do with any languages, let alone a C specific definition. Strictly about computer memory addresses, nothing else.
And you are free to manipulate such addresses as you see fit, in a language and implementation that supports that. However, a C implementation that implements null pointers as pointers to address zero is no such thing. You will have to either change the implementation (pointer to address negative one used to be a popular choice, once upon a time), or use a different language, such as assembly.
C is a more abstract language than people like to think. You are not programming your CPU, you are programming some abstract machine that will at some point be mapped onto your CPU. This indirection means that concepts that have a definite meaning in your world and in the world of your CPU might still be utterly meaningless in the middle step, and be implemented in a manner you did not foresee. In this case, having an object at address zero is to the C machine as a four-sided triangle is to you. It is an utterly alien concept.
PeterX wrote:Hey, guys. It's nice that you keep polite. But you are not convincing each other. So this discussion can go on forever and ever and not leading anywhere...
Agreed, but... hope dies last, alright?