Exercise 31. Common Undefined Behavior
At this point in the book, it’s time to introduce you to the most common kinds of UB that you will encounter. C has 191 behaviors that the standards committee has decided aren’t defined by the standard, and therefore anything goes. Some of these behaviors are legitimately not the compiler’s job, but the vast majority are simply lazy capitulations by the standards committee that cause annoyances, or worse, defects. An example of laziness:
An unmatched “or” character is encountered on a logical source line during tokenization.
In this instance, the C99 standard actually allows a compiler writer to fail at a parsing task that a junior in college could get right. Why is this? Who knows, but most likely someone ...
Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.