I'm reading some internal documentation for code developed to the MISRA C guidelines, and I see that in compiler flags section of the documentation there is a note to compile with optimisation off (
-O0). I'm new to safety-critical development, so in my mind turning off optimisation is overly-pessimistic and modern compilers will produce valid code with moderate optimisation, and anyway a decent test suite will catch compiler flaws.
Are there good arguments for disabling optimisation? Perhaps because of this disabling, the code is riddled with left- and right-shifts replacing divisions and other micro-optimisations that I believe we should leave to the compiler to deal with.