In the code given below, I haven't declared any variable that means I have used 0 bytes or constants are declared in the ROM as in the case of string literal.
#include <stdio.h>
//Compiler version gcc 6.3.0
int main()
{
printf("%d",2*5);
return 0;
}
Constants are stored in various places:
x
by 2, the compiler might generate an instruction that adds x
to itself. So the number 2 never appears in the generated code.3*4+5
, to be evaluated at compile time, resulting in the result 17 being in the program somewhere, while the numbers 3, 4, and 5 will not appear in the program. If the compiler is able to reduce an expression further, some constants might vanish or coalesce.