SystemVerilog OOP Mastery · All levels
Shallow vs Deep Copy: Interview Questions
Interview Questions for Shallow vs Deep Copy.
Interview questions
Q1. What exactly is copied by pkt b = a for class objects?
Answer: Only the handle value is copied, so both handles reference the same runtime object.
Q2. Why can new src still produce aliasing bugs?
Answer: It does member-wise copy; class-typed members are handles, so nested objects remain shared unless deep-copied.
Q3. Where do shallow-copy bugs most often appear in verification?
Answer: At component boundaries that intend snapshots, especially monitor-to-scoreboard and predictor queues.