Compilers

When debugging a program compiled with optimization, some variables may show as "unavailable." What is the main reason?

  1. AWith optimization enabled, debuggers cannot load the program at all
  2. BVariable values change randomly with every compilation
  3. 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.
Practice this topic Back to topic

More Compilers questions

  1. After thoroughly applying constant propagation, constant folding and dead-code elimination to the function above, what does it return and what code remains?
  2. What is the role of lexical analysis in a compiler?
  3. What is done during syntax analysis (parsing) in a compiler?
  4. Which is the best example of an error found during semantic analysis?
  5. Which describes an abstract syntax tree (AST)?