Compiler Optimization
Why Your Variable Disappeared
Source Code
int main(void) {
uint8_t age = 42;
age = 43;
stdio_init_all();
while (true)
printf("age: %d", age);
Compiler Thinks...
age = 42 is NEVER read
Dead store -> REMOVED
age = 43 -> constant fold
Replaces variable with literal
Resulting Assembly
1000023a
2b 21
movs r1, #0x2b
; 0x2b = 43
No age=42 instruction — compiler removed it
Key Takeaway
Source Code
age = 42
age = 43
->
Binary
movs r1, #0x2b
Compiler
Optimizes dead
stores away!