This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49254] New: cannot declare member template as friend of class template
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 1 Jun 2011 12:15:28 +0000
- Subject: [Bug c++/49254] New: cannot declare member template as friend of class template
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49254
Summary: cannot declare member template as friend of class
template
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
template<typename T>
class outer
{
template<typename U>
struct inner
{ };
template<typename U>
friend class outer;
template<typename U>
template<typename>
friend class outer<U>::inner;
public:
outer() { }
};
template class outer<void>;
template class outer<void>::inner<int>;
Gives this error:
priv2.cc: In instantiation of 'outer<void>':
priv2.cc:21:16: instantiated from here
priv2.cc:5:14: error: 'template<class T> template<class U> struct
outer<T>::inner' is private
priv2.cc:5:14: error: within this context
I don't think the friend declaration is actually needed to allow inner<U> to
access outer<T>, but I think it is valid and should be accepted. Comeau and
Clang accept it.