以下代码:
#include <iostream>
#include <array>
using namespace std;
constexpr int N = 1000000;
constexpr int f(int x) { return x*2; }
typedef array<int, N> A;
template<int... i> struct F { static constexpr A f() { return A{{ ::f(i)... }}; } };
template<class A, class B> struct C {};
template<int... i, int... j> struct C<F<i...>, F<j...>> : F<i..., (sizeof...(i)+j)...>
{
using T = F<i..., (sizeof...(i)+j)...>;
};
template<int n> struct S : C<typename S<n/2>::T, typename S<n-n/2>::T> {};
template<> struct S<1> : F<0> { using T = F<0>; };
constexpr auto X = S<N>::f();
int main()
{
cout << X[3] << endl;
}
-std=gnu++11
在 GCC 4.7模式下产生内部编译器错误。
$ g++ -std=gnu++11 test.cpp
g++-4.7.real: internal compiler error: Killed (program cc1plus)
出了什么问题?