This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58896] New: Incorrect handling of a private nested type of a template specialization in the main template
- From: "ville.voutilainen at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 27 Oct 2013 17:54:04 +0000
- Subject: [Bug c++/58896] New: Incorrect handling of a private nested type of a template specialization in the main template
- Auto-submitted: auto-generated
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;
^