Can't see why this shouldn't work with std::shared_ptr; changing the type of m_foo to std::shared_ptr<foo>, i.e. leaving out the redundant template argument, changes nothing; only when making foo a class instead of a class template, and removing all template arguments, does it compile.
co...@weasel:/tmp> g++-mp-4.3 -v Using built-in specs. Target: i386-apple-darwin9.6.0 Configured with: ../gcc-4.3.3/configure --prefix=/opt/local --enable-languages=c,c++,objc,obj-c++,java,fortran --libdir=/opt/local/lib/gcc43 --includedir=/opt/local/include/gcc43 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.3 --with-gxx-include-dir=/opt/local/include/gcc43/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local Thread model: posix gcc version 4.3.3 (GCC) co...@weasel:/tmp> cat t.cc #include <memory> template< typename T > struct foo { std::shared_ptr< foo< T > > m_foo; }; int main() { std::shared_ptr< foo< int > > t; return sizeof( t ); } co...@weasel:/tmp> make t g++-mp-4.3 -O3 -Wall -Wextra -Woverloaded-virtual -std=gnu++0x -m32 -fno-enforce-eh-specs -I/opt/local/include t.cc -o t t.cc: In instantiation of 'foo<int>': /opt/local/include/gcc43/c++/tr1_impl/type_traits:291: instantiated from 'std::is_abstract<foo<int> >' /opt/local/include/gcc43/c++/tr1_impl/type_traits:206: instantiated from 'std::is_function<foo<int> >' /opt/local/include/gcc43/c++/type_traits:127: instantiated from 'std::add_lvalue_reference<foo<int> >' /opt/local/include/gcc43/c++/tr1_impl/boost_shared_ptr.h:463: instantiated from 'std::__shared_ptr<foo<int>, _S_mutex>' /opt/local/include/gcc43/c++/tr1_impl/boost_shared_ptr.h:822: instantiated from 'std::shared_ptr<foo<int> >' t.cc:11: instantiated from here t.cc:6: error: 'foo<T>::m_foo' has incomplete type /opt/local/include/gcc43/c++/tr1_impl/boost_shared_ptr.h:822: error: declaration of 'class std::shared_ptr<foo<int> >' make: *** [t] Error 1 co...@weasel:/tmp> cat b.cc #include <boost/shared_ptr.hpp> template< typename T > struct foo { boost::shared_ptr< foo< T > > m_foo; }; int main() { boost::shared_ptr< foo< int > > t; return sizeof( t ); } co...@weasel:/tmp> make b g++-mp-4.3 -O3 -Wall -Wextra -Woverloaded-virtual -std=gnu++0x -m32 -fno-enforce-eh-specs -I/opt/local/include b.cc -o b co...@weasel:/tmp> -- Summary: std::shared_ptr barfs on incomplete template class that boost::shared_ptr accepts Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gcc at cohi dot at GCC host triplet: i386-apple-darwin9.6.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39405