Compilers
When debugging a program compiled with optimization, some variables may show as "unavailable." What is the main reason?
- AWith optimization enabled, debuggers cannot load the program at all
- BVariable values change randomly with every compilation
- CRegister reuse or removed computations left no value
Show answer and explanation
Answer: C. Register reuse or removed computations left no value
Optimization keeps variables in registers rather than memory and reuses those registers once a value is no longer needed, and constant propagation may remove computations entirely. So when the debugger stops, a variable's value may no longer exist anywhere, and it is shown as "optimized out" or similar. When debugging, it is common to reduce optimization or use a debug-oriented optimization level. Debuggers can still load optimized programs.
- A. Debuggers can load optimized programs.
- B. Values do not change randomly.
- C. Correct. Register reuse or removed computations mean the value no longer exists.