title: How to spot undefined behavior
body: <p>Is there any way to know if you program has undefined behavior in C++ (or even C), short of memorizing the entire spec?</p>
  
  <p>The reason I ask is that I've noticed a lot of cases of programs <a href="https://stackoverflow.com/questions/2722302/can-compiler-optimization-introduce-bugs">working in debug but not release</a> being due to undefined behavior.  It would be nice if there were a tool to at least help spot UB, so we know there's the potential for problems.</p>