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

            Bug ID: 122500
           Summary: GCC incomplete instantiation issue.
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: perdixky at qq dot com
  Target Milestone: ---

GCC appears to instantiate a template class at the wrong moment, so it ends up
touching a specialization that hasn’t finished instantiating. 
It also seems to perform a second, SFINAE-like instantiation during the
process; but in a concept, a failed expression is an error, which causes a
conflict. 
Here is the smallest reproducer I can produce.

#include <array>
#include <cstddef>
#include <utility>

template <typename T>
struct Wrapper : T {};

template <typename T>
struct Struct;

template <typename T>
concept TupleLike = requires { typename T::tuple_like_tag; };

struct A {};

template <typename T>
    requires (!TupleLike<T>)
struct Struct<T> {
    constexpr static std::size_t member_count = 1;

    constexpr static auto names = []<std::size_t...
Is>(std::index_sequence<Is...>) {
        if constexpr (member_count == 0) {
            return std::array<std::size_t, 1>{};
        } else {
            return std::array<std::size_t, member_count>{Is...};
        }
    }(std::make_index_sequence<member_count>{});
};

template <typename T>
struct Struct<Wrapper<T>> {
    constexpr static std::size_t member_count = Struct<T>::member_count;

    constexpr static auto names = []<std::size_t...
Is>(std::index_sequence<Is...>) {
        if constexpr (member_count == 0) {
            return std::array<std::size_t, 1>{};
        } else {
            return std::array<std::size_t, member_count>{Is...};
        }
    }(std::make_index_sequence<member_count>{});
};

using Y = Wrapper<A>;
using trigger = decltype(Struct<Y>::names);

int main() {}

Reply via email to