Is disabling time sensitive interrupts in C a bad idea?
The core problem here is that this compiler apparently decided to re-order inline assembler instructions just as if they were any C code, without having a clue about what those instructions do. So while those instructions might not access any C level variables, they access the very fundamental condition code register!

The compiler is explicitly not allowed to re-order instructions if it would affect the program behavior, period. And it is quite hard to find anything that would affect program behavior more than writes to the most fundamental register in the CPU core.

So this is nonsense behavior and can only be regarded as a compiler bug, likely in the AVR port. 



A possible work-around for this compiler bug might be to introduce a side effect, as specified by the C standard, before the cli() call. One way to do this is to implement ExpensiveOperation() as an actual C function. Note that in the linked example, the expensive operation was not a function. Another way would be to write some dummy code like

ExpensiveOperation();
volatile uint8_t invoke_side_effect = 0;
cli();


Otherwise, standard procedure when encountering a buggy optimizer is to disable that optimizer. If you can find the particular option that allows the compiler to re-order instructions and disable it, that is the best thing to do.