#define SSP_X_SMALL_POOL_SIZE 10 template < class ObjT, unsigned int uiInitialSize > class ObjectFactory { public: virtual ~ObjectFactory(); }; class TD{ public: typedef ObjectFactory< TD, SSP_X_SMALL_POOL_SIZE > Factory; public: friend class TD::Factory; } Compiling the file with gcc gives : New1.cpp:16: Internal compiler error. New1.cpp:16: Internal compiler error: New1.cpp:16: Please submit a full bug report. Any Suggestions or workarounds.
The ICE is fixed in 4.0.4 for sure: [pinskia@celery ~]$ ~/gcc-4.0/bin/gcc t.cc t.cc:16: error: using typedef-name ‘TD::Factory’ after ‘class’ t.cc:13: error: ‘TD::Factory’ has a previous declaration here t.cc:18: error: expected unqualified-id at end of input [pinskia@celery ~]$ ~/gcc-4.1/bin/gcc t.cc t.cc:16: error: using typedef-name ‘TD::Factory’ after ‘class’ t.cc:13: error: ‘TD::Factory’ has a previous declaration here t.cc:18: error: expected unqualified-id at end of input [pinskia@celery ~]$ ~/gcc-local/bin/gcc t.cc t.cc:16: error: using typedef-name ‘TD::Factory’ after ‘class’ t.cc:13: error: ‘TD::Factory’ has a previous declaration here t.cc:18: error: expected unqualified-id at end of input You cannot friend a typedef at least not yet, there is a defect report about that in the C++ standard and another bug filed against GCC for it also but I cannot find it right now.
That would be PR 21498.