On Mon, 21 Mar 2016 13:48:06 -0700 Scott Perry <numist at apple.com> wrote:
> Compilers allow you to choose your standard; --std=c11 means > something very specific (and unchanging) They do. And that covers what the standard covers. The standard also has limits. It includes constructs that are syntactically permitted but whose behavior is left undefined, known by the scarred as "UB" for "undefined behavior". An example from Clang's discussion is int i = 10 << 31; The standard says << is a shift operator. It places no limit on the number of bits to be shifted. If that number is so large that the product cannot be represented by the assigned variable, that is *not* an error. The standard allows the compiler to do anything or nothing with it. As you may imagine, the varieties of anything and nothing are many. Compiler writers are well aware that "nothing" is faster done than "something". Over time, they have gotten more aggressive in simply deleting UB code. As a consequence, programmers who thought they wrote standards-conforming code get burned when they upgrade/change compilers. Mysterious and sometimes subtle errors are introduced by the compiler for the user's benefit. Your googlefu will turn up lots of discussion. One I liked that wasn't on Page 1: http://blog.frama-c.com/index.php?post/2013/10/09/Overflow-float-integer --jkl