This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/7818] protected members still non-reachable from an unbound friend template member function
- From: "lerdsuwa at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Aug 2003 14:37:41 -0000
- Subject: [Bug c++/7818] protected members still non-reachable from an unbound friend template member function
- References: <20020903054601.7818.david.decotigny@irisa.fr>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7818
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2003-08-10 14:37 -------
I think the testcase is invalid, and the correct one should be:
template <class T> struct Y {
void member() {
X<int> c;
c.prot_data = 2;
}
};
template <class S> class X {
int prot_data;
template <class T> friend void Y<T>::member();
};
template class Y<int>;
Here Y<T>::member is declared before it is referenced
in the friend declaration. This is according to 8.3p1
section of the standard:
... When the declarator-id is qualified, the declaration
shall refer to a previously declared member of the class
or namespace to which the qualifier refers, ...
I'm working on a fix for the valid case above.