Hi Ralph, On 7/26/22 14:25, Ralph Corderoy wrote:
Its long been the case that straying into undefined behaviour allows a compiler to optimise away what is stated above as ‘almost certain’, i.e. SIGSEGV. http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html Dereferencing a NULL Pointer: contrary to popular belief, dereferencing a null pointer in C is undefined. It is not defined to trap... NULL pointer dereferences being undefined enables a broad range of optimizations... In C-based languages, NULL being undefined enables a large number of simple scalar optimizations that are exposed as a result of macro expansion and inlining.
Yeah, that's my fear. I think the text in v5 will be a useful middleground. Correct me if not.
But consider the broader ISO C scenario (or old POSIX.1-2001), where NULL isn't defined to be (void*)0. There it isn't so obvious that 0 would also represent a null pointer.On a machine which uses a non-zero bit pattern as its NULL pointer, the constant 0 in a pointer context will be that non-zero bit pattern.
Yeah. Although, I'm considering completely removing any reference to that, on the grounds that that doesn't affect POSIX systems because even though POSIX doesn't make such guarantees yet, all existing POSIX systems de-facto use all 0s to represent a null pointer _and_ a I've been told (I can't find the source now) that a future revision of POSIX is going to make such guarantee.
So, poor non-POSIX users have that problem, but that not our problem.
I find the content of this man page for NULL seems confused. It's mixing reference material from standards with tutorial information for beginners at C programming. I think a man page should contain succinct reference material and leave introductory or exploratory material to accompanying papers. Do the Linux man pages ship accompanying papers, as the original ‘Editions’ of Unix did? Perhaps that's an opening and less constrained format?
No, we don't have accompanying papers.So, I'd like to document what is relevant to programmers. For both beginners and experts. I'll still try to be very succinct, and thank you all for helping me trim the page down a lot.
For accompanying papers, these days, we have the standards documents themselves, and also the many programming online forums, so I don't want to be adding yet another documentation format.
Thanks, Alex -- Alejandro Colomar <http://www.alejandro-colomar.es/>
OpenPGP_signature
Description: OpenPGP digital signature