Bug 139445 - Template Inheritance Problem
Template Inheritance Problem
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
3
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
http://www.new.ox.ac.uk/~chris/compil...
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-15 18:36 EST by Chris Tromans
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-11-16 05:13:25 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Chris Tromans 2004-11-15 18:36:30 EST
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 05:13:25 EST
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.