This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/8056: Friends and partial specializations

>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
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
gcc 3.2
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...




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]