[Bug c++/53307] internal crash with variadic templates and decltype
chesstr at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Thu May 10 20:11:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53307
--- Comment #2 from chesstr at hotmail dot com 2012-05-10 20:09:44 UTC ---
Comment on attachment 27366
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27366
better test case
>#include <iostream>
>template<class...Ts> struct tuple{};
>
>struct funct{
> template<class T,class...argTs>
> T operator()(T arg1,argTs...args){
> return arg1;
> }
>};
>
>template<class...>class test;
>
>template< template <class...> class tp,
> class...arg1Ts,
> class...arg2Ts>
>class test<tp<arg1Ts...>,tp<arg2Ts...>>{
>public:
>template<class func>
>auto test_pass(func fun,arg2Ts...arg2s) -> decltype(fun(arg2s...))
>{
> int gcc_compiles_this;
> int internal_gcc_crash=sizeof...(arg2s);
> return fun(arg2s...);
>}
>template<class func,class...arg3Ts>
>auto testbug(func fun,arg2Ts...arg2s,arg3Ts...arg3s) -> decltype(fun(arg2s...,arg3s...))
>{
> int clang_compiles_but_not_gcc;
> int internal_gcc_crash=sizeof...(arg2s);
> return fun(arg2s...,arg3s...);
>}
>};
>
>int main(){
> test<tuple<>,tuple<char,int>> t;
> std::cout<<t.test_pass(funct(),'a',2);
> std::cout<<t.testbug(funct(),'a',2,100.123);//works fine
> //std::cout<<t.testbug(funct(),'a',2,"str");//fails <<<<<<<<<<<<<<<<<------------------------
> std::cout<<"gcc crash : "<<t.testbug(funct(),'a',2);//fails <<<<<<<<<<<<<<<<<<<--------------
>}
More information about the Gcc-bugs
mailing list