Difficulty: Easy
Correct Answer: All of the above
Explanation:
Introduction / Context:
Storage assignment in a compiler (sometimes called memory layout or allocation) maps program objects to specific locations. This includes source-level variables, compiler-generated temporaries, and literal constants that must exist at runtime. Understanding this phase clarifies how compiled code accesses data efficiently and safely.
Given Data / Assumptions:
Concept / Approach:
The compiler back end assigns addresses or offsets. It lays out activation records for procedures, creates slots for temporaries produced during expression evaluation, and emits data segments for constants. It ensures alignment, size, and lifetime rules are respected (static vs. automatic), often guided by calling conventions and ABI requirements.
Step-by-Step Solution:
Verification / Alternative check:
Inspect generated assembly: look for symbol table entries, .data/.rodata segments for literals, and stack frame (prologue/epilogue) indicating local and temporary allocations.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing runtime heap allocation (done by allocators at execution time) with compile-time storage assignment; overlooking that literals also require addresses and initial contents.
Final Answer:
All of the above.
Discussion & Comments