Title
Padding in class types
Status
review
Section
7.6.2.5 [expr.sizeof]
Submitter
Jim X

Created on 2022-07-19.00:00:00 last changed 4 days ago

Messages

Date: 2026-02-07.08:33:12

Proposed resolution (2026-02-07):

  1. Add a new entry in Clause 3 [intro.defs]:

    3.nn [defns.impl.prop]

    property of the implementation
    behavior, for a well-formed program (3.68 [defns.well.formed]) construct and correct data, that depends on the implementation

  2. 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)
  3. 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: ... ]
Date: 2022-07-19.00:00:00

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.

History
Date User Action Args
2026-02-07 08:33:12adminsetstatus: open -> review
2022-07-19 00:00:00admincreate
2022-07-16 08:34:33adminsetmessages: + msg6888