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

            Bug ID: 123827
           Summary: [reflection] ICE: in verify_unstripped_args - when
                    creating a pack of meta::info
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kirshamir at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/PY9Ka7587

#include <tuple>
#include <meta>
#include <array>

template<std::meta::info... types_pack>
struct MetaTypesHolder {};

template <std::size_t... Is>
consteval auto to_types_holder_impl(const std::ranges::random_access_range
auto& v, std::index_sequence<Is...>) {
    return MetaTypesHolder<v[Is]...>{};
}

template <std::size_t N>
consteval auto to_types_holder(const std::ranges::random_access_range auto& v)
{
    return to_types_holder_impl(v, std::make_index_sequence<N>{});
}

template <std::size_t... Is>
consteval auto to_tuple_impl(const std::ranges::random_access_range auto& v,
std::index_sequence<Is...>) {
    return std::make_tuple(v[Is]...);
}

template <std::size_t N>
consteval auto to_tuple(const std::ranges::random_access_range auto& v) {
    return to_tuple_impl(v, std::make_index_sequence<N>{});
}

// internal compiler error
constexpr auto types1a() {
    return to_types_holder<1>(std::array{^^int});
}

// internal compiler error
template<typename T>
constexpr auto types1b() {
    return to_types_holder<1>(std::array{^^int});
}

template<typename T>
constexpr auto types2() {
    return to_tuple<1>(std::array{^^int});
}

int main() {
    // fail - internal compiler error on both
    constexpr auto a1 = types1a();
    constexpr auto a2 = types1b<void>();

    // ok - works fine:
    constexpr auto b2 = types2<void>();
    static_assert(std::get<0>(b2) == ^^int);
}

Reply via email to