[Bug c++/20578] New: Problem with templates
The following C++ code does not compile, which I believe it should (It compiles on gcc 1.1.1 and Microsoft's VS.NET): Code start template class A { protected: int a; }; template class B: public A { public: void f() { a = 5; } }; Code end I get the following error: test.cpp: In member function `void B::f()': test.cpp:10: error: `a' undeclared (first use this function) test.cpp:10: error: (Each undeclared identifier is reported only once for each function it appears in.) asterix:components/mde> /pack/gcc/3.4.3/bin/g++ test.cpptest.cpp: In member function `void B::f()': test.cpp:10: error: `a' undeclared (first use this function) test.cpp:10: error: (Each undeclared identifier is reported only once for each function it appears in.) -- Summary: Problem with templates Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mah at systematic dot dk CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20578
[Bug c++/20578] Problem with templates
--- Additional Comments From mah at systematic dot dk 2005-03-21 15:49 --- Subject: RE: Problem with templates Thank you for an extreemly quick response. My code is now compiling:-) Med venlig hilsen / kind regards Martin Hansen Lead Architect, Products Systematic Software Engineering A/S Søren Frichs Vej 39, DK-8000 Aarhus C Tel.: +45 8943 2123 Fax: +45 8943 2020 Web: www.systematic.dk -Original Message- From: pinskia at gcc dot gnu dot org [mailto:[EMAIL PROTECTED] Sent: 21. marts 2005 16:33 To: Martin Hansen Subject: [Bug c++/20578] Problem with templates --- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-21 15:32 --- No this should not compile. a is not dependent so it needs to be looked up at the point of the definition and not instaination. Read the 3.4.x release notes to figure out how to fix your code. -- What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20578 --- You are receiving this mail because: --- You reported the bug, or are watching the reporter. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20578