title: Why not always use compiler optimization?
body: <p><a href="https://stackoverflow.com/questions/7124058/compiler-optimization-causing-program-to-run-slower">One of the questions that I asked some time ago</a> had undefined behavior, so compiler optimization was actually causing the program to break.</p>
  
  <p>But if there is no undefined behavior in you code, then is there ever a reason not to use compiler optimization? I understand that sometimes, for debugging purposes, one might not want optimized code (please correct me if I am wrong). Other than that, on production code, why not always use compiler optimization?</p>
  
  <p>Also, is there ever a reason to use, say, <code>-O</code> instead of <code>-O2</code> or <code>-O3</code>?</p>