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++/18311] New: member visibility in inherited template classes


Hi,

I think I have found a bug related to template inheritance: parent class members
seem not to be accessible from public derived classes despite the members'
visibility (public/protected/private).

Please refer to the code below.

The code does not compile, complaining about the variable 'member' not being
defined.
I believe it is a bug because:
- the same compiles fine with non template classes
- the same compiles fine if I inherit from a specifi template (eg hello<int>)

while logically I would expect all of the above to behave in the same way in
this context.

Regards,
Enrico Costanza

---

#include <iostream>

using namespace std;

template  <class T>
class hello {
	public:
		int member;
	public:
	hello() {}
};

template <class P>
class world: public hello<P> {
public:
    world() { member = 9;
    cerr << "hello" << endl;
 }
};

int main(int arc, char** argv)
{
     world<int> hmm;
     return 0;
}

-- 
           Summary: member visibility in inherited template classes
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: enrico_groups at libero dot it
                CC: gcc-bugs at gcc dot gnu dot org


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


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