Question
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:
- (I) Backpatching can be used to generate code for Boolean expression in one pass.
- (II) Backpatching can be used to generate code for flow-of-control statements in one pass.
Which ONE of the following options is CORRECT?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2025 answer key
Solution
Recall how truelist, falselist, and nextlist enable single-pass code generation for both Boolean expressions and control-flow statements.
Backpatching overcomes the problem of unknown branch targets during single-pass intermediate code generation by maintaining synthesized lists of incomplete jump instructions (truelist and falselist for Boolean expressions, and nextlist for flow-of-control statements like if, if-else, and while) and filling in target labels once they become known. Thus both (I) and (II) are correct.
Option (C)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 21 of 65
- 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.