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

2024-11-11


538. Definition and usage of structure, POD-struct, POD-union, and POD class

Section: Clause 11  [class]     Status: CD1     Submitter: Alisdair Meredith     Date: 10 August 2005

[Voted into WP at April, 2007 meeting.]

There are several problems with the terms defined in Clause 11 [class] paragraph 4:

A structure is a class defined with the class-key struct; its members and base classes (11.7 [class.derived]) are public by default ( 11.8 [class.access]). A union is a class defined with the class-key union; its members are public by default and it holds only one data member at a time (11.5 [class.union]). [Note: aggregates of class type are described in 9.4.2 [dcl.init.aggr]. —end note] A POD-struct is an aggregate class that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-declared copy assignment operator and no user-declared destructor. Similarly, a POD-union is an aggregate union that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-declared copy assignment operator and no user-declared destructor. A POD class is a class that is either a POD-struct or a POD-union.
  1. Although the term structure is defined here, it is used only infrequently throughout the Standard, often apparently inadvertently and consequently incorrectly:

    There does not appear to be a reason for defining the term structure. The one reference where it is arguably useful, in the note in 7.6.1.5 [expr.ref], could be rewritten as something like, “'class objects' may be defined using the class, struct, or union class-keys; see Clause 11 [class].”

  2. Based on its usage later in the paragraph and elsewhere, “POD-struct” appears to be intended to exclude unions. However, the definition of “aggregate class” in 9.4.2 [dcl.init.aggr] paragraph 1 includes unions. Furthermore, the name itself is confusing, leading to the question of whether it was intended that only classes defined using struct could be POD-structs or if class-classes are included. The definition should probably be rewritten as, “A POD-struct is an aggregate class defined with the class-key struct or the class-key class that has no...

  3. In most references outside Clause 11 [class], POD-struct and POD-union are mentioned together and treated identically. These references should be changed to refer to the unified term, “POD class.”

  4. Noted in passing: 17.2 [support.types] paragraph 4 refers to the undefined terms “POD structure” and (unhyphenated) “POD union;” the pair should be replaced by a single reference to “POD class.”

Proposed resolution (April, 2006):

  1. Change Clause 11 [class] paragraph 4 as indicated:

    A structure is a class defined with the class-key struct; its members and base classes (11.7 [class.derived]) are public by default ( 11.8 [class.access]). A union is a class defined with the class-key union; its members are public by default and it holds only one data member at a time (11.5 [class.union]). [Note: aggregates of class type are described in 9.4.2 [dcl.init.aggr]. —end note] A POD-struct is an aggregate class that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-declared copy assignment operator and no user-declared destructor. Similarly, a POD-union is an aggregate union that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-declared copy assignment operator and no user-declared destructor. A POD class is a class that is either a POD-struct or a POD-union. A POD class is an aggregate class that has no non-static data members of non-POD type (or array of such a type) or reference, and has no user-declared copy assignment operator and no user-declared destructor. A POD-struct is a POD class defined with the class-key struct or the class-key class. A POD-union is a POD class defined with the class-key union.
  2. Change 11.8.3 [class.access.base] paragraph 2 as indicated:

    In the absence of an access-specifier for a base class, public is assumed when the derived class is declared defined with the class-key struct and private is assumed when the class is declared defined with the class-key class. [Example:...
  3. Delete the note in 7.6.1.5 [expr.ref] paragraph 4:

    [Note: “class objects” can be structures (11.4 [class.mem]) and unions (11.5 [class.union]). Classes are discussed in Clause 11 [class]. —end note]
  4. Change the commentary in the example in 11.4 [class.mem] paragraph 11 as indicated:

    ...an integer, and two pointers to similar structures objects of the same type. Once this definition...

    ...the count member of the structure object to which sp points; s.left refers to the left subtree pointer of the structure object s; and...

  5. Change _N4567_.17.3 [definitions] “iostream class templates” as indicated:

    ...the argument traits is a structure class which defines additional characteristics...
  6. Change 17.6 [support.dynamic] paragraph 4 as indicated:

    If type is not a POD structure or a POD union POD class (clause 9), the results are undefined.
  7. Change the third bullet of Clause Annex B [implimits] paragraph 2 as indicated:

  8. Change the nineteenth bullet of Clause Annex B [implimits] paragraph 2 as indicated:

  9. Change the twenty-first bullet of Clause Annex B [implimits] paragraph 2 as indicated:

  10. Change C.8 [diff.library] paragraph 6 as indicated:

    The C++ Standard library provides 2 standard structures structs from the C library, as shown in Table 126.
  11. Change the last sentence of 6.8 [basic.types] paragraph 10 as indicated:

    Scalar types, POD-struct types, POD-union types POD classes (Clause 11 [class]), arrays of such types and cv-qualified versions of these types (6.8.5 [basic.type.qualifier]) are collectively called POD types.

    Drafting note: Do not change 6.8 [basic.types] paragraph 11, because it's a note and the definition of “layout-compatible” is separate for POD-struct and POD-union in 11.4 [class.mem].

(This resolution also resolves issue 327.)