Skip to content

Incorrect example for member access expression with using enum in [enum.udecl] CWG2959 #7368

Open
@keinflue

Description

@keinflue

[enum.udecl]/2 contains this example:

enum class fruit { orange, apple };
struct S {
  using enum fruit;             // OK, introduces orange and apple into S
};
void f() {
  S s;
  s.orange;                     // OK, names fruit​::​orange
  S::orange;                    // OK, names fruit​::​orange
}

While it is correct that name lookup for orange in s.orange will find fruit::orange, the member access expression itself is not ok, because [expr.ref]/7.5 only specifies its behavior for member enumerators. using enum however doesn't make the enumerator a member enumerator ([class.mem.general]/3.5, [class.mem.general]/4).

Currently [expr.ref] simply lacks a statement about the behavior in this situation, but CWG issue 2902's proposed resolution would clarify that it is ill-formed.

From issue reported to Clang here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions