https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116703

            Bug ID: 116703
           Summary: Use of enum from a template instantiation fails for no
                    apparent reason
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eyalroz1 at gmx dot com
  Target Milestone: ---

(original StackOverflow discussion:
https://stackoverflow.com/q/73479613/1593077)

Consider the following code:


    enum kind_t { kind1, kind2 };

    template <kind_t Kind> struct foo {};

    template <> struct foo<kind1> {
       enum named : int;
    };

    enum foo<kind1>::named : int {
         named1 = 123,
         named2 = 456,
    };


This fails to compile with GCC 14.2, but compiles with MSVC 19.40 and clang
18.1.0: 
https://godbolt.org/z/basEfMj8M

The error message is:

error: cannot add an enumerator list to a template instantiation
    9 | enum foo<kind1>::named : int {
      |      ^~~~~~~~~~

AFAICT, this code should work.

Reply via email to