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
[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.
Although the term structure is defined here, it is used only infrequently throughout the Standard, often apparently inadvertently and consequently incorrectly:
7.6.1.5 [expr.ref] paragraph 4: the use is in a note and is arguably correct and helpful.
11.4 [class.mem] paragraph 11: the term is used (three times) in an example. There appears to be no reason to use it instead of “class,” but its use is not problematic.
_N4567_.17.3 [definitions] “iostream class templates:” the traits argument to the iostream class templates is (presumably unintentionally) constrained to be a structure, i.e., to use the struct keyword and not the class keyword in its definition.
Clause Annex B [implimits] paragraph 2: the minimum number of declarator operators is given for structures and unions but not for classes defined using the class keyword.
Clause Annex B [implimits] paragraph 2: class, structure, and union are used as disjoint terms in describing nesting levels. (The nonexistent nonterminal struct-declaration-list is used, as well.)
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].”
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...
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.”
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):
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 andit 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.
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 isdeclareddefined with the class-key struct and private is assumed when the class isdeclareddefined with the class-key class. [Example:...
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]
Change the commentary in the example in 11.4 [class.mem] paragraph 11 as indicated:
...an integer, and two pointers to
similar structuresobjects of the same type. Once this definition......the count member of the
structureobject to which sp points; s.left refers to the left subtree pointer of thestructureobject s; and...
Change _N4567_.17.3 [definitions] “iostream class templates” as indicated:
...the argument traits is astructureclass which defines additional characteristics...
Change 17.6 [support.dynamic] paragraph 4 as indicated:
If type is not aPOD structure or a POD unionPOD class (clause 9), the results are undefined.
Change the third bullet of Clause Annex B [implimits] paragraph 2 as indicated:
Pointer, array, and function declarators (in any combination)
modifying an a class, arithmetic, structure,
union, or incomplete type in a declaration [256].
Change the nineteenth bullet of Clause Annex B [implimits] paragraph 2 as indicated:
Data members in a single class, structure, or union [16 384].
Change the twenty-first bullet of Clause Annex B [implimits] paragraph 2 as indicated:
Levels of nested class, structure, or union definitions in a
single struct-declaration-list
member-specification [256].
Change C.8 [diff.library] paragraph 6 as indicated:
The C++ Standard library provides 2 standardstructuresstructs from the C library, as shown in Table 126.
Change the last sentence of 6.8 [basic.types] paragraph 10 as indicated:
Scalar types,POD-struct types, POD-union typesPOD 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.)