//class we're trying to generate
template <int a, foo b>
class A
{
public:
A()
{
std::cout << a << "," << (int)b << std::endl;
}
};
//class which generates information
template <typename T>
struct B
{
typedef T value_type;
static const T val;
};
template <typename... B>
struct madscience_intitializer
{
template <typename B::value_type... args>
using ret_type = A<args...>;
};
int main()
{
madscience_intitializer<B<int>,B<foo> >::ret_type<1,foo::y> a;
}
In G++, I get
/home/njclimer/source/testdir/main/main2.cpp: In function 'int main()':
/home/njclimer/source/testdir/main/main2.cpp:38:61: internal compiler error: in dependent_type_p, at cp/pt.c:19526
madscience_intitializer<B<int>,B<foo> >::ret_type<1,foo::y> a;
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccAhk6TK.out file, please attach this to your bugreport.
Has anyone else run into this? Is this an actual bug with the compiler or is it a bug in my code?
I'm running
g++ (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)
^
With flags -std=gnu++0x -O2 -g
Obviously the compiler should not crash, but your code wouldn't compile anyway I think.
You can't pass non-integral types as template parameters, and this:
template using ret_type = A;
Should be
using ret_type = A;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.