This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug c++/58896] New: Incorrect handling of a private nested type of a template specialization in the main template


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58896

            Bug ID: 58896
           Summary: Incorrect handling of a private nested type of a
                    template specialization in the main template
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

This code compiles without any problem:

template<typename> class Obj; 
template<> class Obj<void> { 
  struct secret{}; 
}; 
template<typename T> class Obj { 
  Obj<void>::secret m; 
};

int main()
{ 
  Obj<int> obj; 
}

It's as if the main template somehow manages to be a friend of its
specialization. When the nested name is a typedef, it's diagnosed:

template<typename> class Obj; 
template<> class Obj<void> { 
  typedef int secret; 
}; 
template<typename T> class Obj { 
  Obj<void>::secret m; 
};

int main()
{ 
  Obj<int> obj; 
}

This results in

edoceo.cpp: In instantiation of âclass Obj<int>â:
edoceo.cpp:11:12:   required from here
edoceo.cpp:3:15: error: âtypedef int Obj<void>::secretâ is private
   typedef int secret; 
               ^
edoceo.cpp:6:14: error: within this context
   Obj<void>::secret m; 
              ^

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