Bug 29503

Summary: Internal Compiler Error with Friend + Template + Typedef
Product: gcc Reporter: Mangesh Joshi <mangeshaj>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: major CC: gcc-bugs
Priority: P3    
Version: unknown   
Target Milestone: 4.0.4   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Mangesh Joshi 2006-10-18 16:37:40 UTC
#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.
Comment 1 Andrew Pinski 2006-10-18 17:12:05 UTC
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.
Comment 2 David Fang 2006-10-18 20:25:25 UTC
That would be PR 21498.