Because the compiler does not know that value of capture_number can change on external event (interrupt), so it presumes it's value will not change unexpectedly.You can check disassembly code to see what the compiler did, sometimes it will even throw out the code if it thinks it does nothing.