g++-2.95.1 mess with nested templates and inheritance

Markus Werle markus@lufmech.rwth-aachen.de
Wed Oct 13 07:56:00 GMT 1999


Hi folks!

The following code compiles fine with gcc-2.95 and does what I expected,
but with g++-2.95.1 we get some nasty problem:

> g++ --version
2.95.1

> g++ Bug_in_gcc-2.95.1.C
Bug_in_gcc-2.95.1.C: In method `void
FrontMemoryManagement::Inner::SetValue<A>(const double &)':
Bug_in_gcc-2.95.1.C:36:   instantiated from
`FrontMemoryManagement::SetValue<A>(const double &)'
Bug_in_gcc-2.95.1.C:57:   instantiated from here
Bug_in_gcc-2.95.1.C:41: no matching function for call to
`FrontMemoryManagement::Inner::EvenMoreInner::SetValue (const double &)'


I ran into this because gcc-2.95 has some other problems with nested
templates, but I could not cook the original problem down to a simple example
and updated: Now this problem here occurs :-(

Code:
-----------------------------------------------------------


#include <iostream>

enum Type { A, B };


class FrontMemoryManagement { // all the smart pointer details ommitted
  // ------------------------------------------------------------
  class Inner {
    // ----------------------------------------------------------
    class EvenMoreInner {
    public:
      template <Type T>
      inline void SetValue(const double& value);
    };
    // end of EvenMoreInner declaration
    // ----------------------------------------------------------
  public:
    template <Type T>
    inline void SetValue(const double& value);
  private:
    EvenMoreInner ei_;
  };
  // end of Inner declaration
  // ------------------------------------------------------------
public:
  template <Type T>
  inline void SetValue(const double& value);

private:
  Inner i_;
};


template <Type T>
inline void FrontMemoryManagement::SetValue(const double& value) {
  return  i_.SetValue<T>(value);
}

template <Type T>
inline void FrontMemoryManagement::Inner::SetValue(const double& value) {
  return  ei_.SetValue<T>(value);
}

template <Type T>
inline void FrontMemoryManagement::Inner::EvenMoreInner::SetValue
(const double& value) {
  // do something ...
  cerr << "I am doing something" << endl;
}


template<Type T> class Front : public FrontMemoryManagement {};


int main() {
  Front<B> Test;
  Test.SetValue<A>(5);
}






More information about the Gcc-bugs mailing list