In a comment to this answer on the usage of Anonymous enum, Oli Charlesworth states that:
const int is immutable, and may not take up any space, depending on
what the compiler chooses to do.
If I declare const int i = 10, how is that 10 stored if it “may not take up any space”?
Assuming that an int is 4 bytes, I would presume that at least 4 bytes is reserved to store 10 as a const int.
The compiler is free to optimise code as it sees fit, so long as the resulting code offers the same observable side effects.
So variables may be optimised to only exist in registers, or replaced with immediate values. In pseudo-machine-code:
could become:
or even just: