The fact that it has side effects cause it to work correctly.
If a class only modifies its internal data, it has no side effects and the compiler can optimise it away.
However this class ( or group of classes ) write to external data during destruction, the status register/SREG. More importantly, it reads from an external source marked as volatile ( SREG ) during construction so the compiler is forced to omit instructions.