Bug 29503 - Internal Compiler Error with Friend + Template + Typedef
Summary: Internal Compiler Error with Friend + Template + Typedef
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 major
Target Milestone: 4.0.4
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-18 16:37 UTC by Mangesh Joshi
Modified: 2006-10-18 20:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.