This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-01-24


2609. Padding in class types

Section: 7.6.2.5  [expr.sizeof]     Status: open     Submitter: Jim X     Date: 2022-07-19

Class types may have padding, influencing the result of sizeof. It is unclear whether the placement and amount of padding is implementation-defined, unspecified, or something else. If it is unspecified, the limits of permissible behavior are unclear. Empty classes might need special consideration.

Possible resolution:

  1. Change in 4.1.2 [intro.abstract] paragraph 2 as follows:

    Certain aspects and operations of the abstract machine are described in this document as implementation-defined behavior (for example, sizeof(int)) or as properties of the implementation (for example, padding in class types). These constitute the parameters of the abstract machine. Each For implementation-defined behavior, each implementation shall include documentation describing its characteristics and behavior in these respects. Such documentation shall define the instance of the abstract machine that corresponds to that implementation (referred to as the “corresponding instance” below)
  2. Change in 7.6.2.5 [expr.sizeof] paragraph 2

    ... When applied to a class, the result is the number of bytes in an object of that class including any padding required for placing objects of that type in an array. The amount and placement of padding in a class type is a property of the implementation. The result of applying sizeof to a potentially-overlapping subobject is the size of the type, not the size of the subobject. [ Footnote: ... ]