3 ms·
One important piece of historical context this article doesn't talk about: a lot of the undefined behavior in C is there for compatibility, not for optimization
by hwayne 5y ago
One important piece of historical context this article doesn't talk about: a lot of the undefined behavior in C is there for compatibility, not for optimization. C came out in 1972 while the first official C standard is from 1989. The standard had to be backwards-compatible with all of the major compilers, which had almost 20 years to diverge. That's the source of a lot of undefined and implementation-defined behavior.
- userbinator 5y agoIndeed, the standard even says one of the possible effects of UB is "behaving during translation or program execution in a documented manner characteristic of the environment" and I feel that was really the original intent.
- josephcsible 5y agoThat's the intent for a tiny handful of things that are UB, e.g., "#define _GNU_SOURCE". But for most things, e.g., out-of-bounds array access or use-after-free, it's definitely not.
- userbinator 5y agoThat sounds like revisionism. Look up "spirit of C"... or see what Kernighan and Ritchie said.