g++: Internal compiler error 61 with egcs-980214 (from CVS-source tree)

Bernd Nottelmann nottelm@ptp283.uni-muenster.de
Sun Feb 15 08:30:00 GMT 1998


Hi!

Playing with Todd Veldhuizen's expression templates I
found the following piece of code which causes an
internal compiler error:


--------------------------------snip--------------------------------

template < class T,
           template < class T > class E1,
           template < class T > class E2 >
class Add {
  E1<T> e1_;
  E2<T> e2_;

public:
  Add(const E1<T>& e1, const E2<T>& e2) : e1_(e1), e2_(e2) {}

  inline T operator()(const T& t) const {
    return e1_(t)+e2_(t);
  }
};


template < class T,
           template < class T > class E1,
           template < class T > class E2 >
class Mul {
  E1<T> e1_;
  E2<T> e2_;

public:
  Mul(const E1<T>& e1, const E2<T>& e2) : e1_(e1), e2_(e2) {}

  inline T operator()(const T& t) const {
    return e1_(t)*e2_(t);
  }
};


template < class T >
class Lit {
  T t_;

public:
  Lit(const T& t) {
    t_=t;
  }

  inline T operator()(const T& t) const {
    return t_;
  }
};


template < class T >
struct Id {
  Add < T, Id, Lit > operator+(const T& t) const {
    return Add < T, Id, Lit >(this, Lit<T>(t));
  }

  Mul < T, Id, Lit > operator*(const T& t) const {
    return Mul < T, Id, Lit >(this, Lit<T>(t));
  }

  inline T operator()(const T& t) const {
    return t;
  }
};

template < class T, template < class > class E >
Add < T, Lit, E > operator+(const T& t, const E<T>& e) {
  return Add < T, Lit, E >(Lit<T>(t), e);
}

template < class expr >
double eval(const expr& e, double n) {
  return e(n);
}

int main() {
  Lit<double> x(33);
  eval(5.+x, 12);
}

--------------------------------snip--------------------------------


# g++ bug.C
bug.C:54: Internal compiler error 61.
bug.C:54: Please submit a full bug report to `egcs-bugs@cygnus.com'.

I built egcs only from the gcc-directory (thus without the additional
libs: unfortunately I have at the moment no time to test the total package).
My configuration is

linux-2.0.33
binutils-2.8.1.0.21
libc.so.5.4.33
libstdc++.so.27.2.8

# gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.91.08/specs
gcc version egcs-2.91.08 980214 (gcc-2.8.0 release)

When I took the entire Id-struct away or its operator+(...)-/operator*(...)-method,
the error has vanished.

Bernd





More information about the Gcc-bugs mailing list