* [Bug c++/13495] Friendship to class nested withint a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
@ 2003-12-27 16:45 ` giovannibajo at libero dot it
2004-02-23 15:40 ` lerdsuwa at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2003-12-27 16:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2003-12-27 09:03 -------
It's been clarified by DR180 that the form:
friend class A<T>::B;
is the only allowed. In fact, the name is implicitily a type because of
the 'class' keyword put in front of it, so a typename is not needed (and it is
not allowed by syntax either). This has been correctly implemented by the new
parser in GCC 3.4.
Then you must understand the difference between:
template<class T> class OtherClass {
friend class A<T>::B;
};
and:
template<class T> class OtherClass {
template <class Q>
friend class A<Q>::B;
};
In the first case, you're saying that, for each OtherClass<X>, A<X>::B is a
friend (only for the same X!). In the second, you're saying that for each
OtherClass<X>, any A<Y>::B is a friend (for any Y).
Nonetheless, there is indeed a bug in GCC. I propose this testcase:
--------------------------------------------
template<typename T>
class A{
public:
class B
{
void func1(void);
void func2(void);
};
};
template<typename Q>
class F1
{
friend class A<Q>::B;
enum { foo = 0 };
};
template<typename Q>
class F2
{
template<typename T>
friend class A<T>::B;
enum { foo = 0 };
};
template <typename T>
void A<T>::B::func1(void)
{
(void)F1<T>::foo; // OK, A<T>::B is a friend for this T (#1)
(void)F2<T>::foo; // OK, any A<K>::B is a friend (#2)
}
template <typename T>
void A<T>::B::func2(void)
{
(void)F1<double>::foo; // ERROR, A<double>::T is not a friend (#3)
(void)F2<double>::foo; // OK, any A<K>::B is a friend (#4)
}
template class A<void>;
--------------------------------------------
Thus, GCC should emit an error only for #3. Instead it emits an error for #2
and not for #3. This is clearly a bug (but not a regression, since the previous
versions of GCC were even more broken wrt friendships to nested classes or
specializations of templates).
This is a job for Kriang :)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |accepts-invalid, rejects-
| |valid
Last reconfirmed|0000-00-00 00:00:00 |2003-12-27 09:03:43
date| |
Summary|Impossible "friend"-ship to |Friendship to class nested
|nested template |withint a template is broken
Version|3.3 |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested withint a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
2003-12-27 16:45 ` [Bug c++/13495] Friendship to class nested withint a template is broken giovannibajo at libero dot it
@ 2004-02-23 15:40 ` lerdsuwa at gcc dot gnu dot org
2004-08-30 15:33 ` giovannibajo at libero dot it
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-02-23 15:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |lerdsuwa at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested withint a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
2003-12-27 16:45 ` [Bug c++/13495] Friendship to class nested withint a template is broken giovannibajo at libero dot it
2004-02-23 15:40 ` lerdsuwa at gcc dot gnu dot org
@ 2004-08-30 15:33 ` giovannibajo at libero dot it
2004-08-31 10:56 ` lerdsuwa at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-30 15:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-08-30 15:33 -------
Kriang, it looks like g++.old-deja/g++.pt/friend44.C is related to this bug.
The testcase is xfailed on mainline, and you already fixed half of it with your
patch for PR5369. I guess your patch for this bug also cures that testcase?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested withint a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
` (2 preceding siblings ...)
2004-08-30 15:33 ` giovannibajo at libero dot it
@ 2004-08-31 10:56 ` lerdsuwa at gcc dot gnu dot org
2004-09-04 15:59 ` lerdsuwa at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-08-31 10:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-08-31 10:56 -------
Yes, the patch will also fix the warning produced
when testing g++.old-deja/g++.pt/friend44.C.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested withint a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
` (3 preceding siblings ...)
2004-08-31 10:56 ` lerdsuwa at gcc dot gnu dot org
@ 2004-09-04 15:59 ` lerdsuwa at gcc dot gnu dot org
2004-09-06 15:56 ` lerdsuwa at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-09-04 15:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-09-04 15:59 -------
Patch in progress. Note that even with the fix,
GCC still doesn't diagnose the code in Comment #1
correctly because of PR16617.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested withint a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
` (4 preceding siblings ...)
2004-09-04 15:59 ` lerdsuwa at gcc dot gnu dot org
@ 2004-09-06 15:56 ` lerdsuwa at gcc dot gnu dot org
2004-10-20 16:21 ` [Bug c++/13495] Friendship to class nested within " cvs-commit at gcc dot gnu dot org
2004-10-20 16:25 ` lerdsuwa at gcc dot gnu dot org
7 siblings, 0 replies; 10+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-09-06 15:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-09-06 15:55 -------
Patch submitted:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg00557.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested within a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
` (5 preceding siblings ...)
2004-09-06 15:56 ` lerdsuwa at gcc dot gnu dot org
@ 2004-10-20 16:21 ` cvs-commit at gcc dot gnu dot org
2004-10-20 16:25 ` lerdsuwa at gcc dot gnu dot org
7 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-20 16:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-10-20 16:20 -------
Subject: Bug 13495
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: lerdsuwa@gcc.gnu.org 2004-10-20 16:20:51
Modified files:
gcc/cp : ChangeLog cp-tree.h decl.c friend.c parser.c
pt.c
gcc/testsuite : ChangeLog
gcc/testsuite/g++.old-deja/g++.pt: friend44.C
Added files:
gcc/testsuite/g++.dg/template: memfriend9.C memfriend10.C
memfriend11.C memfriend12.C
memfriend13.C memfriend14.C
memfriend15.C memfriend16.C
memfriend17.C
Log message:
PR c++/13495
* decl.c (make_unbound_class_template): Add PARM_LIST parameter.
* cp-tree.h (make_unbound_class_template): Adjust prototype.
* parser.c (cp_parser_lookup_name): Adjust call to
make_unbound_class_template.
(cp_parser_single_declaration): Handle member class of class
template as template friend parsing correctly.
* friend.c (is_friend): Call is_specialization_of_friend for
template friend class.
(make_friend_class): Handle member class of class template as
template friend.
* pt.c (is_specialization_of_friend): Likewise.
(instantiate_class_template): Likewise.
(tsubst): Adjust call to make_unbound_class_template.
* g++.dg/template/memfriend9.C: New test.
* g++.dg/template/memfriend10.C: Likewise.
* g++.dg/template/memfriend11.C: Likewise.
* g++.dg/template/memfriend12.C: Likewise.
* g++.dg/template/memfriend13.C: Likewise.
* g++.dg/template/memfriend14.C: Likewise.
* g++.dg/template/memfriend15.C: Likewise.
* g++.dg/template/memfriend16.C: Likewise.
* g++.dg/template/memfriend17.C: Likewise.
* g++.old-deja/g++.pt/friend44.C: Remove bogus error.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4447&r2=1.4448
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1065&r2=1.1066
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1316&r2=1.1317
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/friend.c.diff?cvsroot=gcc&r1=1.101&r2=1.102
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.267&r2=1.268
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.936&r2=1.937
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4478&r2=1.4479
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend10.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend12.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend13.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend14.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend15.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend16.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/memfriend17.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.pt/friend44.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13495] Friendship to class nested within a template is broken
2003-12-27 7:46 [Bug c++/13495] New: Impossible "friend"-ship to nested template sstrasser at systemhaus-gruppe dot de
` (6 preceding siblings ...)
2004-10-20 16:21 ` [Bug c++/13495] Friendship to class nested within " cvs-commit at gcc dot gnu dot org
@ 2004-10-20 16:25 ` lerdsuwa at gcc dot gnu dot org
7 siblings, 0 replies; 10+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-10-20 16:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-10-20 16:25 -------
I am closing this as fixed by patch:
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01709.html
For access checking problem mentioned in the comments, it's
already covered in PR16617. That part requires some structural
changes that won't be investigated for some time.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13495
^ permalink raw reply [flat|nested] 10+ messages in thread