Understanding BSS and DATA segments in C++ static storage
This is a medium-difficulty systems-level question that tests your understanding of how a C++ compiler organizes memory for variables with static storage duration. It appears frequently in interviews at firms that care about low-level performance and memory layout—particularly those doing systems programming or high-frequency trading infrastructure.
The question requires you to distinguish between the BSS segment (uninitialized static data) and the DATA segment (initialized static data), then classify a series of declarations accordingly. The key insight is recognizing which variables are explicitly initialized at compile time versus which are zero-initialized by the runtime. Your reasoning matters more than a single "correct" answer, since compiler behavior can vary; interviewers are assessing whether you understand the principles that drive segment assignment.
- Static storage duration and linkage in C++
- Compile-time initialization versus zero-initialization
- Memory layout and linker behavior
- How explicit initializers affect segment placement