I am trying to get the product of all variadic template arguments given to a basic struct. At looks like follows:
template<int a, int ... as>
struct A {
int data[doIt<a, as...>()];
};
And I constructed doIt<>()
in multiple levels. I found out that this is the only way it should work. I got this solution from this stackoverflow question. The code looks loke follows:
template<int ... is>
constexpr std::size_t doIt();
template<int i, int ... is>
constexpr std::size_t doIt_helper() {
return i * doIt<is...>(); // this row throws the error
}
template<>
constexpr std::size_t doIt<>() {
return 1;
}
template<int ... is>
constexpr std::size_t doIt() {
return doIt_helper<is...>();
}
And when I try to compile the code I get: internal compiler error: in instantiate_decl, at cp/pt.c:22741
and I am supposed to report the bug to gcc. But I want to make sure that I didn't do the mistake. I am compiling with g++ -std=c++17
. And the version is gcc version 7.5.0
. What's going on?