PracHub
QuestionsLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Discord

Explain C++ alignment and ABI stability

Last updated: Mar 29, 2026

Quick Overview

This question evaluates mastery of C++ low-level memory concepts—memory alignment, padding and struct/class layout—and understanding of ABI stability, including calling conventions, name mangling, vtable layout and other binary compatibility concerns, reflecting competence in systems-level C++ and binary interfacing.

  • hard
  • Discord
  • Software Engineering Fundamentals
  • Software Engineer

Explain C++ alignment and ABI stability

Company: Discord

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: HR Screen

You are interviewing for a senior C++ / systems role. The interviewer asks two low-level fundamentals questions: 1. **C++ memory alignment and padding** - Explain what *memory alignment* means in C and C++. - Describe what *padding* is inside and at the end of structs/classes. - Show with a small example how the order of data members can change the `sizeof` a struct due to padding. - Discuss why alignment and padding exist (performance, hardware constraints) and what problems they can cause (e.g., unexpected struct size, binary compatibility issues, undefined behavior if misaligned). - Mention typical ways to inspect or control layout when absolutely necessary (e.g., compiler-specific pragmas/attributes, `static_assert(sizeof(...))`, etc.), and the risks of doing so. 2. **ABI (Application Binary Interface) and its instability** - Define what an ABI (Application Binary Interface) is, and how it differs from a source-level API. - Explain which aspects are covered by an ABI (e.g., calling conventions, data layout, alignment, name mangling, exception handling, vtable layout). - Explain why the C++ ABI is often *not stable* across different compilers or even different versions of the same compiler, while C ABIs tend to be much more stable. - Give concrete examples of problems ABI instability can cause in practice (e.g., linking a program against a shared library built with a different compiler/version, plugin systems, distributing precompiled libraries). - Describe common engineering strategies to mitigate ABI issues in C++ (e.g., using a stable C interface boundary with `extern "C"`, avoiding STL types in public ABI, the PImpl idiom, rebuilding all components with the same toolchain). Explain your answers in a way that shows deep understanding of low-level details and practical trade-offs.

Quick Answer: This question evaluates mastery of C++ low-level memory concepts—memory alignment, padding and struct/class layout—and understanding of ABI stability, including calling conventions, name mangling, vtable layout and other binary compatibility concerns, reflecting competence in systems-level C++ and binary interfacing.

Related Interview Questions

  • Explain your database experience and debugging approach - Discord (hard)
  • Demonstrate effective AI-assisted coding workflow - Discord (medium)
  • Debug and mitigate a CPU spike incident - Discord (medium)
|Home/Software Engineering Fundamentals/Discord

Explain C++ alignment and ABI stability

Discord logo
Discord
Dec 8, 2025, 12:00 AM
hardSoftware EngineerHR ScreenSoftware Engineering Fundamentals
8
0

You are interviewing for a senior C++ / systems role. The interviewer asks two low-level fundamentals questions:

  1. C++ memory alignment and padding
    • Explain what memory alignment means in C and C++.
    • Describe what padding is inside and at the end of structs/classes.
    • Show with a small example how the order of data members can change the sizeof a struct due to padding.
    • Discuss why alignment and padding exist (performance, hardware constraints) and what problems they can cause (e.g., unexpected struct size, binary compatibility issues, undefined behavior if misaligned).
    • Mention typical ways to inspect or control layout when absolutely necessary (e.g., compiler-specific pragmas/attributes, static_assert(sizeof(...)) , etc.), and the risks of doing so.
  2. ABI (Application Binary Interface) and its instability
    • Define what an ABI (Application Binary Interface) is, and how it differs from a source-level API.
    • Explain which aspects are covered by an ABI (e.g., calling conventions, data layout, alignment, name mangling, exception handling, vtable layout).
    • Explain why the C++ ABI is often not stable across different compilers or even different versions of the same compiler, while C ABIs tend to be much more stable.
    • Give concrete examples of problems ABI instability can cause in practice (e.g., linking a program against a shared library built with a different compiler/version, plugin systems, distributing precompiled libraries).
    • Describe common engineering strategies to mitigate ABI issues in C++ (e.g., using a stable C interface boundary with extern "C" , avoiding STL types in public ABI, the PImpl idiom, rebuilding all components with the same toolchain).

Explain your answers in a way that shows deep understanding of low-level details and practical trade-offs.

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Discord•More Software Engineer•Discord Software Engineer•Discord Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 9,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.