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

            Bug ID: 119398
           Summary: partial ordering of nested class template
                    specializations fails with NTTP of nested class type
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following is valid C++20:


template <class T>
struct outer {
  struct value_type {
    T value{};
    constexpr value_type() = default;
    constexpr value_type(T v) : value(v) {}
  };

  template <auto, value_type...>
  struct inner;

  template <auto _>
  struct inner<_, value_type{}, value_type{}> {};

  template <auto _, value_type I>
  struct inner<_, I, value_type{}> {};

  template <auto _, value_type J>
  struct inner<_, value_type{}, J> {};

  template <auto _, value_type I, value_type J>
  struct inner<_, I, J> {};
};

int main() {
  [[maybe_unused]]
  outer<int>::inner<0, 0, 1> i{};
}



GCC rejects it with:


<source>: In function 'int main()':
<source>:28:30: error: ambiguous template instantiation for 'struct
outer<int>::inner<0, outer<int>::value_type{0}, outer<int>::value_type{1}>'
   28 |   outer<int>::inner<0, 0, 1> i{};
      |                              ^


It fails on trunk. I've also tested as far back as gcc-12, and it has never
worked.


https://godbolt.org/z/vfP5Y9hG9

Reply via email to