GATE CS 2025 Set 2 — Question 21
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+1 / -0.33EasyBackpatchingIntermediate Code GenerationCompiler Design
Compiler Design → Intermediate Code Generation → Backpatching
Last updated
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?
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.Which ONE of the following options is CORRECT?
Correct answer
(C) Both (I) and (II) are correct.
Solution
Backpatching is a technique used in the intermediate code generation phase of a compiler. It is primarily used to generate code for boolean expressions and flow-of-control statements in a single pass.When generating code for boolean expressions (like
(I) is TRUE: Backpatching allows single-pass generation for Boolean expressions (short-circuit evaluation involves jumps).
(II) is TRUE: Backpatching allows single-pass generation for flow-of-control statements.Hence, both statements are correct.
a < b or A || B) and control flow statements (like if, while), the compiler often needs to generate jump instructions. In a single-pass compiler, the target address (label) of a forward jump is not known at the moment the jump instruction is generated.Backpatching solves this by generating the jump instruction with an empty or placeholder target and adding the location of this instruction to a list. Later, when the target label is determined, the compiler goes back and fills in (backpatches) the correct address in all the instructions on the list.Therefore:(I) is TRUE: Backpatching allows single-pass generation for Boolean expressions (short-circuit evaluation involves jumps).
(II) is TRUE: Backpatching allows single-pass generation for flow-of-control statements.Hence, both statements are correct.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Intermediate Code Generation
2026 Set 2 Q17In C runtime environment, which one of the following is stored in heap?2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]2026 Set 1 Q28Which of the following statements is/are true?2026 Set 2 Q35A lexical analyzer uses the following token definitions - - …