Bug 101687 (cwg2557) - Scoped enumerators of a member enumeration shall not be referred by a class member access expression
Summary: Scoped enumerators of a member enumeration shall not be referred by a class m...
Status: SUSPENDED
Alias: cwg2557
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: c++-core-issues
  Show dependency treegraph
 
Reported: 2021-07-30 08:45 UTC by jim x
Modified: 2023-01-10 05:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jim x 2021-07-30 08:45:05 UTC
struct A{
    enum class C{
        a = 0
    };
};
int main(){
   A a;
   auto c = a.C::a;  //#1
}

> Each enum-name and each unscoped enumerator is declared in the scope that immediately contains the enum-specifier. 

> An enumerator declared in class scope can be referred to using the class member access operators (​::​, . (dot) and -> (arrow)), see [expr.ref].

According to the above rule, A::C::a shouldn't appear in the id-expression of a member access expression, which means `#1` should be ill-formed.
Comment 1 Andrew Pinski 2021-08-05 10:12:13 UTC
Confirmed.

GCC 4.7.4 used to ICE on this.
Comment 2 Andrew Pinski 2022-12-29 02:24:49 UTC
Hmm, MSVC also accepts this code but clang does not.
Comment 3 jim x 2023-01-10 05:44:37 UTC
I think CWG2557 is clear with this aspect https://cplusplus.github.io/CWG/issues/2557.html
Comment 4 Andrew Pinski 2023-01-10 05:48:08 UTC
Suspending as the defect report is still considered open but is in the process of drafting:
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2557