Question
Which one of the following is NOT performed during compilation?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2014 answer key
Solution
Distinguish compiler phases and tasks (compile time) from execution tasks (runtime).
-
Tasks performed during compilation:
- Type checking: Performed during the semantic analysis phase to ensure operands and operations have compatible types.
- Symbol table management: Maintained across all analysis and synthesis phases to track identifiers, types, scopes, and memory offsets.
- Inline expansion: Performed during the code optimization phase to replace function calls with function bodies to reduce call overhead.
-
Dynamic memory allocation:
- Allocation of memory on the heap (e.g., via
malloc()orcalloc()in C, ornewin C++) occurs dynamically while the program runs, depending on runtime inputs and execution flow. - Therefore, dynamic memory allocation is performed at runtime, NOT during compilation.
- Allocation of memory on the heap (e.g., via
Final answer
A
Common trap
Confusing compile-time static memory layout (calculating offsets in activation records) with runtime dynamic allocation on the heap.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 2
- Question
- 28 of 65, printed as CS Q.18
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.