http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52109

             Bug #: 52109
           Summary: Apparently endless recursive instantiation
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: vegard.nos...@gmail.com


#include <tuple>
#include <type_traits>

template<typename... Args>
void x(Args... args) {
        x(std::tuple<Args...>(args...));
}

void y()
{
        x();
}

This seems to put the compiler into an endless loop, with errors looking like
this:

In file included from test3.cc:1:0:
/usr/include/c++/4.6/tuple: In member function ‘std::_Tuple_impl<_Idx, _Head,
_Tail ...>::_Inherited& std::_Tuple_impl<_Idx, _Head, _Tail ...>::_M_tail()
[with long unsigned int _Idx = 0ul, _Head = std::tuple<std::tuple<> >, _Tail =
{}, std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Inherited =
std::_Tuple_impl<1ul>]’:
/usr/include/c++/4.6/tuple:174:43:   instantiated from ‘std::_Tuple_impl<_Idx,
_Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _Head, _Tail ...>&&)
[with long unsigned int _Idx = 0ul, _Head = std::tuple<std::tuple<> >, _Tail =
{}, std::_Tuple_impl<_Idx, _Head, _Tail ...> = std::_Tuple_impl<0ul,
std::tuple<std::tuple<> > >]’
test3.cc:6:2:   recursively instantiated from ‘void x(Args ...) [with Args =
{std::tuple<>}]’
test3.cc:6:2:   instantiated from ‘void x(Args ...) [with Args = {}]’
test3.cc:11:4:   instantiated from here
/usr/include/c++/4.6/tuple:154:51: error: ‘std::_Tuple_impl<1ul>’ is an
ambiguous base of ‘std::_Tuple_impl<0ul, std::tuple<std::tuple<> > >’
/usr/include/c++/4.6/tuple: In member function ‘std::_Tuple_impl<_Idx, _Head,
_Tail ...>::_Inherited& std::_Tuple_impl<_Idx, _Head, _Tail ...>::_M_tail()
[with long unsigned int _Idx = 0ul, _Head = std::tuple<std::tuple<std::tuple<>
> >, _Tail = {}, std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Inherited =
std::_Tuple_impl<1ul>]’:
/usr/include/c++/4.6/tuple:174:43:   instantiated from ‘std::_Tuple_impl<_Idx,
_Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _Head, _Tail ...>&&)
[with long unsigned int _Idx = 0ul, _Head = std::tuple<std::tuple<std::tuple<>
> >, _Tail = {}, std::_Tuple_impl<_Idx, _Head, _Tail ...> =
std::_Tuple_impl<0ul, std::tuple<std::tuple<std::tuple<> > > >]’
test3.cc:6:2:   recursively instantiated from ‘void x(Args ...) [with Args =
{std::tuple<>}]’
test3.cc:6:2:   instantiated from ‘void x(Args ...) [with Args = {}]’
test3.cc:11:4:   instantiated from here
/usr/include/c++/4.6/tuple:154:51: error: ‘std::_Tuple_impl<1ul>’ is an
ambiguous base of ‘std::_Tuple_impl<0ul, std::tuple<std::tuple<std::tuple<> > >
>’
/usr/include/c++/4.6/tuple: In member function ‘std::_Tuple_impl<_Idx, _Head,
_Tail ...>::_Inherited& std::_Tuple_impl<_Idx, _Head, _Tail ...>::_M_tail()
[with long unsigned int _Idx = 0ul, _Head =
std::tuple<std::tuple<std::tuple<std::tuple<> > > >, _Tail = {},
std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Inherited = std::_Tuple_impl<1ul>]’:
/usr/include/c++/4.6/tuple:174:43:   instantiated from ‘std::_Tuple_impl<_Idx,
_Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _Head, _Tail ...>&&)
[with long unsigned int _Idx = 0ul, _Head =
std::tuple<std::tuple<std::tuple<std::tuple<> > > >, _Tail = {},
std::_Tuple_impl<_Idx, _Head, _Tail ...> = std::_Tuple_impl<0ul,
std::tuple<std::tuple<std::tuple<std::tuple<> > > > >]’
test3.cc:6:2:   recursively instantiated from ‘void x(Args ...) [with Args =
{std::tuple<>}]’
test3.cc:6:2:   instantiated from ‘void x(Args ...) [with Args = {}]’
test3.cc:11:4:   instantiated from here
[...]

(Or is this unfixable as a manifestation of the halting problem?)

Reply via email to