This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30508] New: Inherited inner template classes cannot access protected base data members
- From: "support at stonesteps dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jan 2007 04:45:26 -0000
- Subject: [Bug c++/30508] New: Inherited inner template classes cannot access protected base data members
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The code between the dashed lines generates these errors:
test2.cpp: In member function 'void outer_t::inner_derived_t<type_t>::f2()':
test2.cpp:20: error: 'i' was not declared in this scope
command line:
$ cc -o test2 test2.cpp
If i is accessed through "this" pointer, the code compiles:
template <typename type_t>
void outer_t::inner_derived_t<type_t>::f2(void)
{
int i2 = this->i; // <-- this works
}
----------------------------------------
class outer_t {
public:
template <typename type_t>
class inner_t {
protected:
int i;
};
template <typename type_t>
class inner_derived_t : public inner_t<type_t> {
public:
void f2(void);
};
};
template <typename type_t>
void outer_t::inner_derived_t<type_t>::f2(void)
{
int i2 = i; // <-- error
}
int main(int argc, char* argv[])
{
outer_t::inner_derived_t<int> id;
id.f2();
return 0;
}
----------------------------------------
--
Summary: Inherited inner template classes cannot access protected
base data members
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: support at stonesteps dot ca
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30508