Several compilers used nonzero values internally to represent the null pointer. You might find such a definition in the header files commonly used with these compilers. The C standard says the integer 0 converted to a pointer to void is a null pointer, so headers often define NULL as "((void*)0)" and let the compiler work out exactly which internal representation to use.bzt wrote:And since you were so consistent, I'd like to kindly ask you to show us one implementation that defines NULL other than 0.
GCC explicitly states that any pointer-sized integer converted to a pointer will use the same internal representation, which means that a pointer to address 0 will be a null pointer in GCC. I seem to recall finding a patch for GCC that changed the internal null pointer representation to a different bit pattern, but I can't find it now. If I recall correctly, this patched version of GCC still used 0 converted to a pointer to represent null, and used a different nonzero integer when converting to or from a pointer to address 0.
bzt wrote:Without a header, there's no NULL, and without NULL there's no NULL dereference, period.
The standard does not require the NULL macro to be defined for there to be a null pointer.C99 draft WG14/N1256 section 6.3.2.3 paragraph 3 wrote:An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
I thought we were talking about compiler bugs you uncovered while developing POSIX-UEFI? I don't have any particularly strong feelings about the POSIX-like interface, but I can see how it can be a useful abstraction. (Does its file handling also work with TFTP for PXE boot?)bzt wrote:Is it really too hard to focus on POSIX-UEFI? Please keep on topic!
gcc (Debian 8.3.0-6) 8.3.0bzt wrote:Which version are you using?