On 11/06/2015 01:32 PM, David Brown wrote: > How about this case: > > int foo(int x) { > if (x > 1290) { > printf("X is wrong here %d, but we don't care\n", x); > } > return x*x*x; > } > > The compiler can eliminate the check and the printf. I don't think the compiler can do that because printf has an externally visible effect, which is sequenced before the undefined behavior, so this program transformation would not be permitted under the as-if rule. Florian