reload.c:5855:... error.... reg_overlap_mentioned_for_reload_p

David Mazieres dm@reeducation-labor.lcs.mit.edu
Wed Jul 8 11:50:00 GMT 1998


In recent versions of egcs, for instance:

Reading specs from /usr/local/egcs/lib/gcc-lib/i386-netbsd/egcs-2.91.47/specs
gcc version egcs-2.91.47 19980707 (gcc2 ss-980609 experimental)

I am getting a lot of these internal compiler errors.  I'm afraid the
bug is a bit finicky, so I was only able to get it to occur with a
fairly large piece of test code.  However, when I compile the
following code on the i386 (OpenBSD) without exceptions, I get:

% c++ -fno-exceptions -c -O reload-bug.C 
../../egcs/gcc/reload.c:5855: Internal compiler error in function reg_overlap_mentioned_for_reload_p
% 

Thanks,
David

==

#include <cstddef>
#include <sys/types.h>

#define New new

struct refcount {
  int cnt;
  void refcount_inc () { cnt++; }
  void refcount_dec () { if (!--cnt) delete this; }
  refcount () : cnt (0) {}
  virtual ~refcount () {}
};

template<class T>
struct refcounted
  : virtual public refcount, public T
{
  refcounted () {}
  template<class A1>
  refcounted (const A1 &a1)
    : T (a1) {}
  template<class A1, class A2>
  refcounted (const A1 &a1, const A2 &a2)
    : T (a1, a2) {}
  template<class A1, class A2, class A3>
  refcounted (const A1 &a1, const A2 &a2, const A3 &a3)
    : T (a1, a2, a3) {}
  template<class A1, class A2, class A3, class A4>
  refcounted (const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
    : T (a1, a2, a3, a4) {}
};

template<class T>
struct ref {
  refcount *c;
  T *p;

  void refcount_inc () const { c->refcount_inc (); }
  void refcount_dec () const { c->refcount_dec (); }

  ref (const ref &r)
    : c (r), p (r) { refcount_inc (); }
  template<class U> ref (const U &r)
    : c (r), p (r) { refcount_inc (); }
  const ref &operator= (const ref &r)
    { r.refcount_inc (); refcount_dec (); c = r.c; p = r.p; return *this; }

  operator refcount *() const { return c; }
  operator T *() const { return p; }
  T *operator-> () const { return p; }
  T &operator* () const { return *p; }
};

template<class R, class B1 = void, class B2 = void, class B3 = void>
class callback;

template<class R, class B1>
class callback<R, B1> {
public:
  typedef ref<callback<R, B1> > ref;

  virtual R operator() (B1) = 0;
  virtual ~callback () {}
};

template<class C, class R, class B1, class A1>
class callback1_c_1;

template<class C, class B1, class A1>
class callback1_c_1<class C, void, class B1, class A1>
  : public callback<void, B1> {
  typedef void (C::*cb_t) (A1, B1);
  C *c;
  cb_t f;
  A1 a1;
  callback1_c_1 ();
public:
  callback1_c_1 (C *cc, cb_t ff, const A1 &aa1)
    : c (cc), f (ff), a1 (aa1) {}
  void operator() (B1 b1) {
    (c->*f) (a1, b1);
  }
};

template<class C, class R, class B1, class A1, class AA1>
static inline refcounted<callback1_c_1<C, R, B1, A1> > *
wrap (C *c, R (C::*f) (A1, B1), const AA1 &a1)
{
  return New (refcounted<callback1_c_1<C, R, B1, A1> >) (c, f, a1);
}

typedef callback<void, int>::ref cbi;

struct foo {

  void fa (cbi);
  void fb (cbi, int);
  void fc (cbi);
};

void
foo::fa (cbi cb)
{
  (*cb) (0);
}

void
foo::fb (cbi cb, int status)
{
}

void
foo::fc (cbi cb)
{
  fa (wrap (this, &fb, cb));
}



More information about the Gcc-bugs mailing list