Re: Counterexamples in C programming and library documentation (was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-08-09 Thread James K. Lowden
On Tue, 2 Aug 2022 14:06:45 -0500 "G. Branden Robinson" wrote: > (the "root of all evil" thing), which also got stuffed into > Donald Knuth's mouth Knuth did say it. Please see " Structured Programming with go to Statements" mentioned in "ACM Computing Surveys Vol. 6, No. 4" at htt

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-08-06 Thread Alejandro Colomar
Hi Doug, On 7/27/22 15:23, Douglas McIlroy wrote: I agree with all of Ingo's comments. A man page is a reference, not a history, not a tutorial, not a style guide, There s nothing to say about NULL beyond it's being a synonym for the constant 0 converted to the null pointer. Other facts about th

Re: Counterexamples in C programming and library documentation (was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-08-04 Thread Alejandro Colomar
Hi Branden, On 8/3/22 17:58, G. Branden Robinson wrote: At 2022-08-03T01:54:18+0200, Alejandro Colomar wrote: Could you show an example? I'm curious. Sure. Let me quote Andrew Koenig, _C Traps and Pitfalls_, Addison-Wesley, 1989. "I once talked to someone who was writing a C program to ru

Re: Counterexamples in C programming and library documentation (was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-08-03 Thread G. Branden Robinson
Hi Alex, I'll reply to one bit of this for now and the rest later. I need to eat my vegetables (fix that groff man(7) `CHECKSTYLE` warning)--I've got it down to 2 test case failures. At least four of my tests were adequately irascible to find real problems! At 2022-08-03T01:54:18+0200, Alejandr

Re: Counterexamples in C programming and library documentation (was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-08-02 Thread Alejandro Colomar
Hi Branden, On 8/2/22 21:06, G. Branden Robinson wrote: [content warning: yet another long software engineering rant] [this one took me many hours to read completely, including links, but was funny] At 2022-08-02T13:38:22+0200, Alejandro Colomar wrote: On 7/27/22 15:23, Douglas McIlroy w

Counterexamples in C programming and library documentation (was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-08-02 Thread G. Branden Robinson
[content warning: yet another long software engineering rant] At 2022-08-02T13:38:22+0200, Alejandro Colomar wrote: > On 7/27/22 15:23, Douglas McIlroy wrote: > > > > Incidentally, I personally don't use NULL. Why, when C provides a > > crisp notation, 0, should one want to haul in an extra inclu

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-08-02 Thread Alejandro Colomar
Hi Doug, On 7/27/22 15:23, Douglas McIlroy wrote: Incidentally, I personally don't use NULL. Why, when C provides a crisp notation, 0, should one want to haul in an extra include file to activate a shouty version of it? Because I don't know what foo(a, b, 0, 0) is, and I don't know from mem

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-28 Thread Alejandro Colomar
Hi Ingo, On 7/27/22 15:11, Alejandro Colomar wrote: +.SH CONFORMING TO That should be ".SH STANDARDS". We use CONFORMING TO in Linux.  Don't know why; just history, I guess. See man-pages(7). Weird. I failed to find a single instance of "CONFORMING TO" in AT&T UNIX (including v6, PWB, v

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-27 Thread Douglas McIlroy
I agree with all of Ingo's comments. A man page is a reference, not a history, not a tutorial, not a style guide, There s nothing to say about NULL beyond it's being a synonym for the constant 0 converted to the null pointer. Other facts about the behavior of null pointers will have been learned ho

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-27 Thread Alejandro Colomar
Hi Ingo, On 7/27/22 12:49, Ingo Schwarze wrote: Hi Alejandro, Alejandro Colomar wrote on Tue, Jul 26, 2022 at 02:02:56PM +0200: On 7/25/22 20:49, Ingo Schwarze wrote: Alejandro Colomar wrote on Sun, Jul 24, 2022 at 09:19:32PM +0200: +.B 0 There is really no need to mark up integer const

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-27 Thread Ingo Schwarze
Hi Alejandro, Alejandro Colomar wrote on Tue, Jul 26, 2022 at 02:02:56PM +0200: > On 7/25/22 20:49, Ingo Schwarze wrote: >> Alejandro Colomar wrote on Sun, Jul 24, 2022 at 09:19:32PM +0200: >>> +.B 0 >> There is really no need to mark up integer constants. > groff_man_style(7): >

Re: Dereferencing NULL. (Was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-07-26 Thread Alejandro Colomar
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 Dereferenc

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-26 Thread Alejandro Colomar
Hi Jakub, On 7/25/22 20:57, Jakub Wilk wrote: * Alejandro Colomar , 2022-07-24, 21:19: +.B "#define NULL  ((void *) 0)" +.fi +.SH DESCRIPTION +.B NULL +represents a null pointer constant. +.PP +According to POSIX, +it shall expand to an integer constant expression with the value +.B 0 +cast to

Dereferencing NULL. (Was: [PATCH v3] NULL.3const: Add documentation for NULL)

2022-07-26 Thread Ralph Corderoy
Hi Alex and Ingo, Alex wrote: > > > +It is undefined behavior to dereference a null pointer > > > > That is formally true, but hardly helpful in a manual page because > > what happens when you dereference a NULL pointer is faily > > predictable in practice: a segmentation fault. > > > > Any othe

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-26 Thread Alejandro Colomar
Hi Ingo, On 7/25/22 20:49, Ingo Schwarze wrote: Hi Alejandro, Alejandro Colomar wrote on Sun, Jul 24, 2022 at 09:19:32PM +0200: - Move to man3const [Ralph, Branden] - Added LIBRARY section - Added #include [Ralph] - Note that it can also be used as a function pointer [Ralph] - Document that 0

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-25 Thread Jakub Wilk
* Alejandro Colomar , 2022-07-24, 21:19: +.B "#define NULL ((void *) 0)" +.fi +.SH DESCRIPTION +.B NULL +represents a null pointer constant. +.PP +According to POSIX, +it shall expand to an integer constant expression with the value +.B 0 +cast to type +.IR "void *" . Might be worth noting tha

Re: [PATCH v3] NULL.3const: Add documentation for NULL

2022-07-25 Thread Ingo Schwarze
Hi Alejandro, Alejandro Colomar wrote on Sun, Jul 24, 2022 at 09:19:32PM +0200: > - Move to man3const [Ralph, Branden] > - Added LIBRARY section > - Added #include [Ralph] > - Note that it can also be used as a function pointer [Ralph] > - Document that 0 is another null pointer constant [Ralph]

[PATCH v3] NULL.3const: Add documentation for NULL

2022-07-24 Thread Alejandro Colomar
Reported-by: "G. Branden Robinson" Cc: Ralph Corderoy Cc: Ingo Schwarze Signed-off-by: Alejandro Colomar --- v2: - Move to man3const [Ralph, Branden] - Added LIBRARY section - Added #include [Ralph] - Note that it can also be used as a function pointer [Ralph] - Document that 0 is another nu