Just a quick FYI for anyone who missed it. Following the discussion from a few days ago about Cava (C like language with no undefined behavior), gcc 4.9 is now out[1]. One of the changes there is a runtime check for undefined behavior. Just compile with -fsanitize=undefined, and your program will crash with log if it performs an operation that C/C++ considers to be undefined.
Have not tried it myself, but feedback would be great. Shachar [1] http://gcc.gnu.org/gcc-4.9/changes.html