61 karma · joined November 23, 2016
The notion that compilers that encounter undefined behavior are allowed to generate any code they want is a new interpretation, for some value of "new". I can't remember the first time I encountered such an interpretation being used by compiler writers to justify something they wanted to do until sometime after 2000.
The notion that John Regehr has (quoted in the article) that undefined behavior implies the whole execution is meaningless is not supported by the language of either the C89 or C99 standard, at least by my reading. The C89 standard has a notion of sequence points. Wouldn’t all sequence points executed before undefined behavior is encountered be required to occur as if the undefined behavior wasn’t there? It would seem so:
From the C89 standard: 2.1.2.3 Program execution
The semantic descriptions in this Standard describe the behavior of an abstract machine in which issues of optimization are irrelevant. Accessing a volatile object, modifying an object, modifying a file, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment. Evaluation of an expression may produce side effects. At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place.
The C99 standard has nearly identical language:
5.1.2.3 Program execution 1 The semantic descriptions in this International Standard describe the behavior of an abstract machine in which issues of optimization are irrelevant. 2 Accessing a volatile object, modifying an object, modifying a file, or calling a function that does any of those operations are all side effects,11) which are changes in the state of the execution environment. Evaluation of an expression may produce side effects. At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place.
From https://en.wikipedia.org/wiki/Pete_Wilson Wilson was the driving force behind the 1996 legislation that deregulated the state's energy market, which was the first energy utilities deregulation in the U.S. and aggressively pushed by companies such as Enron.[28]
On the front: The more I use Java On the back: The more I love Smalltalk
This was while I was in the middle of writing a compiler front-end and a code generator for a JVM. I decided to write the compiler in Java (eat your own dog food), and the exact kind of do. every. step. at. a. time. in the example here made me long for select: []
To answer the question about why GCs are an issue, a GC scans memory, moving objects, updating pointers, writing marks in special headers, etc.