cplusplus / cplusplus/draft

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

Open
#7,368 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cwg not-editorial
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the example in [enum.udecl]/2 alongside [expr.ref]/7.5 and [class.mem.general]/3.5 and /4. Read the proposed resolution for CWG issue 2902 and the linked Clang report first. Done means the draft's example and wording accurately describe member access through a name introduced by using enum.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.