Question 4 points at a huge surprise. With a scientific computing project, I got (if I recall correctly), correct and expected output at no optimization and -O1, and patently incorrect output at -O2 and -O3.
Cost: one sleepless night in college."What do you mean, optimization doesn't just make it faster?!?"
Really? Wow, I thought optimisations had to provably avoid affecting the correctness of your program. Hence:
"This need to avoid imprecise intermediate results often prevents compilers from exploiting mathematical properties like associativity when optimizing FP arithmetic."
Cost: one sleepless night in college."What do you mean, optimization doesn't just make it faster?!?"