2 ms·
I believe that in the before times, "undefined behavior" meant something could be valid in certain contexts, and erroneous in others (as opposed to "implementat
by bitwize 3y ago
I believe that in the before times, "undefined behavior" meant something could be valid in certain contexts, and erroneous in others (as opposed to "implementation-defined" in which something sensible must be done but it's not clear exactly what). For example, null-pointer indirection has meaning if you're banging bits on the bare metal; it means fetch from (or store to) location 0. But most user-space programs on virtual-memory machines don't use location 0, so null is reserved as an invalid pointer/sentinel value. Many architectures for which C compilers exist trap if you try to access an address outside the bounds of an explicitly allocated buffer; the Symbolics Lisp machines had a C environment in which all pointers were "fat": they contained both a pointer to a Lisp object (typically a vector) and an offset from the beginning of that object. So the semantics of memory accesses in C are meant to accommodate those architectures as well as ones in which memory is assumed to be one big array of fixed-size integers and you can read or write wherever.