-
C Standards: the triumph of bureaucracy

-
C23 standard (final draft)
-
Kuth’s Merge Sort in C

Taken from Knuth Algorithm S mergesort P162-163 Vol 3 Second edition 1998 The major change is that the scratch buffer is not required to be adjacent and there are some changes because C array indexing starts with 0. This is very much how a mathematician writes code. You have to remember a larger than usual…
-
don’t defer
-
Unforgivable C programming 1
Here’s a program that exhibits the low level nature of C by changing the return address of a function. The function “one” always returns the number 1 and the function “two” always returns the number 2. The main code calls “one” and prints out that it returned 1, then calls “two” and then changes its…
-
Threads in C
There is a nice example thread semantics in a paper by David Goldblatt (P1916R0) which illustrates a couple of things about multi-core processing – including how interesting it is and how poorly defined the C11 atomic/thread extension is . A simplified version looks like this: //Example1 int x=0; int y=0; int r1=0; int r2 =0;…
-
Memory model and semantics for C
A perceptive note from Linus Torvalds about the C/C++ “memory model” is reproduced below. From Linus Torvalds <> Date Thu, 7 Jun 2018 08:40:49 -0700 Subject Re: LKMM litmus test for Roman Penyaev’s rcu-rr share 0 On Thu, Jun 7, 2018 at 7:57 AM Alan Stern <stern@rowland.harvard.edu> wrote: > > You can look at a…
-
unfashionable C

In computer science academia, C along with UNIX, and PDP11s, is as unfashionable as can be: the equivalent of other 1970’s relics, like polyester leisure suits and mullets. In 2018 ACM Queue published an essay by David Chisnall called: C Is Not a Low-level Language: Your computer is not a fast PDP-11 that expresses many…
-
Undefined behavior in C is a reading error.
Considering how important “undefined behavior” has become to C semantics and the ISO/IEC JTC1/SC22/WG14 Committee, the lack of any reference to it in the K&R ANSI book is notable and the description in the 1999 C Rationale was quite modest. Undefined behavior gives the implementor license not to catch certain program errors that are difficult…
