Templates Problem comes from gcc

Pascal Francq pfrancq@ulb.ac.be
Wed Feb 23 06:20:00 GMT 2000


The bug that I reported in the last mail has the following origin:

// parent class declaration
template<class T> class foo1  
{
public:
  unsigned int nb;
};

// child class declaration
template<class T> class foo2 : public foo1 
{
public:
  void init(void);
}

// global variable
unsigned int nb; 

// child class definition
template<class T> void foo2<T>:init(void)
{
  for(unsigned i=nb+1;--i;)
  {
     doSomething();
  }
}


The gcc compiler use in the init function the global variable nb and the
variable nb inherits from foo1.
I think this is an error of gcc.
-- 


Ir. Pascal Francq
Researcher
Université Libre de Bruxelles
Faculty of Applied Mechanics
Avenue F.D. Roosevelt, 50
CP 165/41
B-1050 Brussels
BELGIUM
Tel. +32-2-650 47 65
Fax +32-2-650 27 10


More information about the Gcc mailing list