The GATE Grind

GATE 2025 CS (CS2) – Question 21

Compiler Design · Intermediate Code Generation · 1 mark · Multiple choice

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?

  1. Only (I) is correct.
  2. Only (II) is correct.
  3. Both (I) and (II) are correct.
  4. Neither (I) nor (II) is correct.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) Both (I) and (II) are correct.

Explanation

Backpatching fills in jump targets that are unknown when the jump is emitted. It is used for one-pass code generation of both Boolean expressions and flow-of-control statements.