Description
- has no element of the set M(S) of types as a base class, where for any type X, M(X) is defined as follows.104 [Note 2: M(X) is the set of the types of all non-base-class subobjects that may be at a zero offset in X. — end note]
- If X is a union type, the set M(X) is the union of all M(Ui) and the set containing all Ui, where each Ui is the type of the ith non-static data member of X.
The contradiction comes from the fact that a union doesn't have base classes (see this sentence in [class.union]/4). Thus, from the sentence highlighted above in [class.prop]/(3.7), the set M(S) is empty when S is a union, which proves the contradiction with [class.prop]/(3.7.3).
I know that this is not an editorial issue, but the solution is so simple that I decided to give it a try:
[class.prop]/(3.7.3) can simply be eliminated from [class.prop]/(3.7) for the following reason: a union U is a non-standard-layout class if any non-static subobject of class type inside U is non-standard-layout, and this will be caught by paragraph (3.1) , which says:
- has no non-static data members of type non-standard-layout class (or array of such types) or reference,
Otherwise, i.e., if every non-static subobject of class type inside U is a standard-layout class, U is a standard-layout class.
One other solution would be to replace [class.prop]/(3.7.3) with:
- If X is a union type, the set M(X) is empty.
Activity
zygoloid commentedon Sep 21, 2020
The wording is correct as-is. Consider:
Here,
B
is not standard-layout because M(B
) containsA
andB
hasA
as a base class. M(B
) is defined asU
plus M(U
), and M(U
) is defined asA
.So we need M(
U
) to be non-empty for M(B
) to properly compute "the set of the types of all non-base-class subobjects that may be at a zero offset in"U
, even thoughU
itself can't have base class.