Title
A union's associated types should include the union itself
Status
nad
Section
6.5.4 [basic.lookup.argdep]
Submitter
John Spicer

Created on 1999-02-02.00:00:00 last changed 299 months ago

Messages

Date: 1999-04-15.00:00:00

Rationale (04/99): Unions are class types, so the example is well-formed. Although the wording here could be improved, it does not rise to the level of a defect in the Standard.

Date: 2022-02-18.07:47:23

When a union is used in argument-dependent lookup, the union's type is not an associated class type. Consequently, code like this will fail to work.

    union U {
        friend void f(U);
    };

    int main() {
        U u;
        f(u);  // error: no matching f — U is not an associated class
    }
Is this an error in the description of unions in argument-dependent lookup?

Also, this section is written as if unions were distinct from classes. So adding unions to the "associated classes" requires either rewriting the section so that "associated classes" can include unions, or changing the term to be more inclusive, e.g. "associated classes and unions" or "associated types".

Jason Merrill: Perhaps in both cases, the standard text was intended to only apply to anonymous unions.

Liam Fitzpatrick: One cannot create expressions of an anonymous union type.

Rationale (04/99): Unions are class types, so the example is well-formed. Although the wording here could be improved, it does not rise to the level of a defect in the Standard.

History
Date User Action Args
1999-09-14 00:00:00adminsetmessages: + msg188
1999-02-02 00:00:00admincreate