https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123842
Bug ID: 123842
Summary: [reflection] ICE: in cp_parser_splice_expression -
when splicing a subscript in array
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: ---
// see: https://godbolt.org/z/zPGWEG67W
#include <vector>
#include <meta>
#include <array>
template <std::size_t... Is>
consteval auto to_array_impl(const std::ranges::random_access_range auto& v,
std::index_sequence<Is...>) {
return std::array<std::meta::info, sizeof...(Is)>{v[Is]...};
}
template <std::size_t N>
consteval auto to_array(const std::ranges::random_access_range auto& v) {
return to_array_impl(v, std::make_index_sequence<N>{});
}
template<typename Type>
consteval auto get_types() {
constexpr auto vec_factory = []() {
std::vector<std::type_info> types;
auto ctx = std::meta::access_context::current();
for (std::meta::info member : members_of(^^Type, ctx)) {
if (is_operator_function(member)
&& operator_of(member) == std::meta::operators::op_parentheses)
{
auto params = std::meta::parameters_of(member);
if(params.size() == 1 ||
(params.size() > 1 &&
std::meta::has_default_argument(params[1])) ) {
// ICE on the below
types.push_back(
typeid([:std::meta::type_of(params[0]):])
);
// following is fine:
constexpr auto param = params[0];
types.push_back(
typeid([:std::meta::type_of(param):])
);
}
}
}
return types;
};
return to_array<vec_factory().size()>(vec_factory());
}
int main() {}