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.
Three modest proposals for the C standard WG14
Note: these were sent to WG14 as official proposals. See also a longer paper, something on alias and Torvalds remarks and Regehr’s paper. 6.12 Proposal to clarify undefined behavior range for implementations [N 2278] 6.13 Proposal to make aliasing consistent [N
Vector optimization with C aliasing
One of the common defenses of the abuse of “undefined behavior” by C compilers, and the stupid aliasing rules in the standard is that those things are necessary for optimizations, like using vector operations. Here’s an example of where gcc
Torvalds on aliasing
See also PLOS article, pointer alias in C and remarks on the purpose of C. From: LKML From Linus Torvalds <> Date Tue, 5 Jun 2018 10:30:21 -0700 Subject Re: [GIT PULL] Device properties framework update for v4.18-rc1 On Mon, Jun
Depressing and faintly terrifying days for the C standard
C STANDARD UNDEFINED BEHAVIOR VERSUS WITTGENSTEIN 1. DEPRESSING AND FAINTLY TERRIFYING Chris Lattner, the architect of the Clang/LLVM C compiler explained the effects of the C standard’s “undefined behavior (UB): UB is an inseperable part of C programming, […] this
The C standard versus C and the mother of all hacks.
The Kafkaesque interaction of the C standard and the main open source C compilers was concisely outlined by one of the main LLVM authors back in 2011: “knowing that INT_MAX+1 is undefined allows optimizing X+1 > X to “true”. Knowing
The C standard committee effort to kill C continues
Consider the following code: void f(void) { unsigned char x[1]; /* intentionally uninitialized */ x[0] ^= x[0]; printf(“%d\n”, x[0]); printf(“%d\n”, x[0]); return; } In this example, the unsigned char array x is intentionally uninitialized but cannot contain a trap representation because it has a