This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/6695: Regression: template friend declaration doesn't work
- From: benko at sztaki dot hu
- To: gcc-gnats at gcc dot gnu dot org
- Date: 17 May 2002 13:06:06 -0000
- Subject: c++/6695: Regression: template friend declaration doesn't work
- Reply-to: benko at sztaki dot hu
>Number: 6695
>Category: c++
>Synopsis: Regression: template friend declaration doesn't work
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 17 06:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Benko Pal
>Release: 3.1
>Organization:
>Environment:
SuSE 7.3, i686
>Description:
I want all instances of a class template
be friends of each other.
The syntax
template <typename T>
class a
{
template <typename> friend class a;
};
works; it works even if this class is nested in
another class b.
But if this class b is itself a template, then I got an
error. With 3.0.4 it worked.
>How-To-Repeat:
arta:~/c/proba$ g++3 templfriend2.cc
templfriend2.cc: In constructor `b<V>::a<T>::a(const b<V>::a<T*>&) [with T =
char, V = void*]':
templfriend2.cc:44: instantiated from here
templfriend2.cc:12: `char*b<void*>::a<char*>::t_' is private
templfriend2.cc:29: within this context
zsh: exit 1 g++3 templfriend2.cc
arta:~/c/proba$ g++3 templfriend2.cc -DWORKS
arta:~/c/proba$ /gml/shared/gcc-3.0.4/bin/g++ templfriend2.cc
arta:~/c/proba$ g++3 -v
Reading specs from /gml/shared/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc-3.1/configure --prefix=/gml/shared/gcc-3.1 --enable-languages=c++ --with-dwarf2 --enable-threads=posix
Thread model: posix
gcc version 3.1
arta:~/c/proba$ /gml/shared/gcc-3.0.4/bin/g++ -v
Reading specs from /gml/shared/gcc-3.0.4/lib/gcc-lib/i686-pc-linux-gnu/3.0.4/specs
Configured with: ../gcc-3.0.4/configure --prefix=/gml/shared/gcc-3.0.4 --enable-threads=posix --enable-languages=c++
Thread model: posix
gcc version 3.0.4
arta:~/c/proba$
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="templfriend2.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="templfriend2.cc"
IyBpZm5kZWYgV09SS1MKdGVtcGxhdGUgPHR5cGVuYW1lIFY+CiMgZW5kaWYgLy8gV09SS1MKc3Ry
dWN0IGIKewogIHRlbXBsYXRlIDx0eXBlbmFtZSBUPgogIGNsYXNzIGEKICB7CiAgICB0ZW1wbGF0
ZSA8dHlwZW5hbWU+CiAgICBmcmllbmQgY2xhc3MgYTsKCiAgICBUIHRfOwoKICAgcHVibGljOgog
ICAgYSgpIHt9CiAgICBhKGE8VCAqPiBjb25zdCAmKTsKICB9Owp9OwoKIyBpZm5kZWYgV09SS1MK
dGVtcGxhdGUgPHR5cGVuYW1lIFY+CiMgZW5kaWYgLy8gV09SS1MKdGVtcGxhdGUgPHR5cGVuYW1l
IFQ+CmIKIyBpZm5kZWYgV09SS1MKPFY+CiMgZW5kaWYgLy8gV09SS1MKOjphPFQ+OjphKGE8VCAq
PiBjb25zdCAmcmhzKTogdF8oKnJocy50XykKe30KCgppbnQKbWFpbigpCnsKICBiCiMgaWZuZGVm
IFdPUktTCiAgICA8dm9pZCAqPgojIGVuZGlmIC8vIFdPUktTCiAgICA6OmE8Y2hhciAqPiBxOwog
IGIKIyBpZm5kZWYgV09SS1MKICAgIDx2b2lkICo+CiMgZW5kaWYgLy8gV09SS1MKICAgIDo6YTxj
aGFyPiB3KHEpOwoKICByZXR1cm4gMDsKfQo=