[Bug c++/41216] New: G++ failed to correctly resolve the template parameters.
y(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = Inner*, _ForwardIterator = Inner*, bool = false]' d:\mingw-5.1.4\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_uninitialized.h:117: instantiated from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = Inner*, _ForwardIterator = Inner*]' d:\mingw-5.1.4\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_uninitialized.h:257: instantiated from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = Inner*, _ForwardIterator = Inner*, _Tp = Inner]' d:\mingw-5.1.4\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_uninitialized.h:267: instantiated from '_ForwardIterator std::__uninitialized_move_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = Inner*, _ForwardIterator = Inner*, _Allocator = std::allocator]' d:\mingw-5.1.4\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/vector.tcc:338: instantiated from 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = Inner, _Alloc = std::allocator]' d:\mingw-5.1.4\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stl_vector.h:741: instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = Inner, _Alloc = std::allocator]' ..\Src\TestMinGW.cpp:24: instantiated from 'Outter::Outter(IStream&) [with IStream = std::istream]' ..\Src\TestMinGW.cpp:40: instantiated from here ..\Src\TestMinGW.cpp:16: error: no match for 'operator>>' in 'in >> inner->Inner::data' Build error occurred, build is stopped Time consumed: 500 ms. -- Summary: G++ failed to correctly resolve the template parameters. Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yimingli0126 at 163 dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41216
[Bug c++/41216] G++ failed to correctly resolve the template parameters.
--- Comment #1 from yimingli0126 at 163 dot com 2009-09-01 16:16 --- Created an attachment (id=18462) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18462&action=view) The source file rising the compilation failure. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41216
[Bug libstdc++/41216] G++ failed to correctly resolve the template parameters.
--- Comment #5 from yimingli0126 at 163 dot com 2009-09-02 06:59 --- (In reply to comment #4) > Actually, a library issue, invalid, still library. Many thanks for your reply. Yes, it could be a library issue and this problem occurred since v4.3.x. MSVC 8.0/9.0 doesn't have this problem. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41216
[Bug libstdc++/41216] G++ failed to correctly resolve the template parameters.
--- Comment #7 from yimingli0126 at 163 dot com 2009-09-02 10:33 --- Thanks. I have added explicit copy constructors both Inner(Inner const&) and Inner(Inner&) to the class Inner, which are superior to template < class IStream > Inner (IStream&) when the complier decides which should be called, so that now the codes work well. Here are the new sample codes: struct Inner { template < class IStream > friend IStream& operator >> ( IStream& in, Inner& inner ); Inner() : data(0) {} Inner( Inner const& inner ) : data(inner.data) {} // Make the class copy-constructable. Inner( Inner& ); // Only declaration is necessary fo gcc. template < class IStream > explicit Inner( IStream& in ) { operator >> (in,*this); } int data; }; template < class IStream > IStream& operator >> ( IStream& in, Inner& inner ) { in >> inner.data; return in; } struct Outter { template < class IStream > friend IStream& operator >> ( IStream& in, Outter& outter ); Outter() {} Outter( Outter const& outter) {} // Make the class copy-constructable. Outter( Outter& ); // Only declaration is necessary. template < class IStream > explicit Outter( IStream& in ) { operator >> (in,*this); } std::vector inners; }; template < class IStream > IStream& operator >> ( IStream& in, Outter& outter ) { outter.inners.push_back(Inner(in)); return in; } int main ( int argc, char* argv[] ) { Inner inner(std::cin); Outter outter(std::cin); return 0; } Actually, becuase there is a delcaration of Inner(Inner&), the instance of template < class IStream > Outter( IStream& ) with IStream = Inner is suppressed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41216