3 ms·
Not quite. C and C++ standards discriminate between undefined- and implementation-defined behavior. In the latter case, implementaitons can differ, but each mus
by Someone 14y ago
Not quite. C and C++ standards discriminate between undefined- and implementation-defined behavior. In the latter case, implementaitons can differ, but each must choose (and document) some well-defined way to handle a case. A trivial example is "sizeof(int)". The standard does not say much about what it produces (IIRC, it must be an int at least as large as sizeof(char)), so it can return 1, 2, 4, or even 17 (well, maybe not in C11. Newer standards tend to put more restrictions on behavior)
A nontrivial example is the value of "-64 >> 3". More info at http://stackoverflow.com/questions/2397984/undefined-unspecified-and-implementation-defined-behavior http://stackoverflow.com/questions/2397984/undefined-unspeci...
I think the post you reply to refers to the fact that early K&R C predates any standard that introduced the term 'undefined behavior'. At that time, the standard was just 'whatever that tool Kernighan and Ritchie wrote does'.
- bandy 14y agoEven at that point, there was the PDP-11 compiler and the compiler for the Perkins-Elmer implementation, not to mention the (straight) C compiler (/usr/bin/cc) vs the Portable C Compiler, both of which were available on V7. The maxim then (and now) being: Don't Write Silly Code.