<i>It is not OK to just randomly avoid doing optimizations allowed by the C standard because they might trigger bugs. C depends on undefined behavior for performance. You depend on these compiler optimizations to get good performance out of the programs you run every day.</i><p>Geoff offers a simple succinct example of optimizing based on undefined behavior in another comment in this thread: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11147068" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11147068</a><p>I tested with GCC, Clang, MSVC, and ICC, and found that only GCC removed the checks and optimized the function down to a constant.  Clang, MSVC, and ICC instead generated code that matched the programmer&#x27;s clear intent.<p>Are you sure they would be better compilers if they matched GCC&#x27;s behavior here? I agree the GCC authors are far from stupid, but I think there might be a difference in philosophy here rather than just a missed opportunity for optimization.