You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
struct A {};
union U { A a; };
struct B : A { U u; };
Here, B is not standard-layout because M(B) contains A and B has A as a base class. M(B) is defined as U plus M(U), and M(U) is defined as A.
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 though U itself can't have base class.
[class.prop]/(3.7):
[class.prop]/(3.7.3):
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:
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:
The text was updated successfully, but these errors were encountered: