GATE / CS ARCHIVE

GATE CSE 1995 / QUESTION 2.11

Storage of a Pascal variant record

Compiler Design · Runtime Environments & Parameter Passing · Full GATE CSE 1995 paper

GATE 1995, Q2.11 2 marks · MCQ
Report issue

Runtime Environments & Parameter Passing

Question 2.11, GATE 1995: A record has one integer number and alternative fields (x,y:integer) or (p,q:real). With 4-byte integers and 8-byte reals, how much storage for 100 records?
Question 2.11, GATE 1995: A record has one integer number and alternative fields (x,y:integer) or (p,q:real). With 4-byte integers and 8-byte reals, how much storage for 100 records?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 2000 bytes without padding or a stored tag (no official key was published)

Alternative fields share the same region; the record does not store both variants simultaneously. The integer pair needs 8 bytes and the real pair 16, so the variant region must reserve their maximum, 16. Add the common integer field’s 4 bytes to get 20 per record, or 2000 for 100. This assumes the abstract packed/no-padding model and no separately stored discriminant, as the intended choices do. An implementation aligning 8-byte real fields might use 24 bytes per record instead; byte sizes alone do not determine actual ABI padding.

Original paper, page 4