c++/8056: Friends and partial specializations
bangerth@ticam.utexas.edu
bangerth@ticam.utexas.edu
Thu Sep 26 11:56:00 GMT 2002
>Number: 8056
>Category: c++
>Synopsis: Friends and partial specializations
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 26 11:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
gcc 3.2
>Description:
The following small progra shows two problems with friend
declarations and partial specializations:
----------------------------------------
template <int N, typename T> class X;
template <typename T> class X<1,T>;
namespace NS {
class Y {
static int i;
template <int N, typename T> friend class X;
template <typename T> friend class X<1,T>;
};
};
template <typename T> class X<1,T> {
X () { NS::Y::i; }; // access private field
};
template class X<1,int>;-------------------------------------
The first is that gcc3.2 rejects the second friend
declaration. I think it was discussed some time ago that
the present grammar does not allow this anyway, so this
would not be a bug in gcc. icc rejects it as well.
The second problem is that once you remove the offending
line, the partial specialization is no longer a friend, so
should not be able to access the private member. Yet, gcc
compiles this snippet, while icc does not. I guess this
counts as a bug, as annoying it may be since then we are
no longer able to allow partial specializations access to
private members...
Regards
Wolfgang
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list