Bug 139445 - Template Inheritance Problem
Summary: Template Inheritance Problem
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 3
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL: http://www.new.ox.ac.uk/~chris/compil...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-11-15 23:36 UTC by Chris Tromans
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-11-16 10:13:25 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Chris Tromans 2004-11-15 23:36:30 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)
Gecko/20031114

Description of problem:
When compiling the following:

template <class type>
class SuperClass {
   
  protected:
    type *superClassMember;
   
  public:
    SuperClass();
 
};
 
template <class type>
SuperClass<type>::SuperClass() {
  superClassMember = 0;
}

 
template <class type>
class SubClass : public SuperClass<type> {
   
  private:
   
  public:
    SubClass();
     
};
 
template <class type>
SubClass<type>::SubClass() : SuperClass<type>() {
  superClassMember = new type[2];
}
 
int main (int, char **) {
  SubClass<double> *subClass = new SubClass<double>();
  delete subClass;
}

The comiler informs me that superClassMember is not defined:

[cet@proteus bug]$ g++ -Wall -W Test.cpp -o Test
In file included from Test.cpp:1:
SubClass.hpp: In constructor `SubClass<type>::SubClass()':
SubClass.hpp:18: error: `superClassMember' undeclared (first use this
function)
SubClass.hpp:18: error: (Each undeclared identifier is reported only
once for each function it appears in.)

However if I compile under gcc-c++-3.3.2-1 in Fedora Core 1 it
compiles perfectly.


Version-Release number of selected component (if applicable):
gcc-c++-3.4.2-6.fc3

How reproducible:
Always

Steps to Reproduce:
Attempt to compile the classes given in the description.

Additional info:

Comment 1 Jakub Jelinek 2004-11-16 10:13:25 UTC
Please see
http://gcc.gnu.org/gcc-3.4/changes.html
particularly search for
In a template definition, unqualified names will no longer find members of a dependent base.
Also, read the ISO C++ 98 standard.


Note You need to log in before you can comment on or make changes to this bug.