This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Internal compiler error


c++ -Wall -I. -O   -c Staged.cc -o Staged.o
Staged.cc: In method `const struct ListS * staged_append(const ListS
*)::Function1S::operator ()(const struct ListS *) const':
Staged.cc:65: Internal compiler error.
Staged.cc:65: Please submit a full bug report to
`egcs-bugs@cygnus.com'.
make: *** [Staged.o] Error 1
352 ~/cs750/regexp/c++ chen@jonas$ c++ -v
Reading specs from /usr/lib/gcc-lib/i386-linux/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)
353 ~/cs750/regexp/c++ chen@jonas$ uname -a
Linux jonas 2.0.32 #19 Mon Dec 15 01:07:50 EST 1997 i586 unknown

// fun staged_append nil = fn l => l
//      | staged_append (h::t) =
//        let
//            val tail_appender = staged_append t
//        in
//            fn l => h :: tail_appender l
//        end

// For more faithful simulation, would use template <class T> etc.
// But this is just an example.
// Note stuff is const because ML lists are immutable.
class ListS;
typedef const ListS* List;
struct ListS {
  const int hd;
  const List tl;

  ListS(int hd, List tl) : hd(hd), tl(tl) {}
};

// For convenience.
inline List
  cons(int hd, List tl)
{
  return new ListS(hd, tl);
}

inline int
  hd(List l)
{
  return l->hd;
}

inline List
  tl(List l)
{
  return l->tl;
}

const List nil = 0;

inline bool
  null(List l)
{
  return l == 0;
}


// Simulate higher-order function.
class FunctionS;
typedef const FunctionS* Function;
struct FunctionS {
  virtual List operator()(List l) const = 0;
};


class IdentityS;
typedef const IdentityS* Identity;
struct IdentityS : public FunctionS {
  virtual List operator()(List l) const {
    return l;
  }
};

const Identity identity = new IdentityS();




Function
  staged_append(const List l)
{
  if (null(l)) {
    return identity;
  }
  else {
    const Function tail_appender = staged_append(tl(l));

    struct Function1S : public FunctionS {
      // This corresponds to what is going on underneath in ML.
      const int h;
      const Function tail_appender;

      Function1S(int h, Function tail_appender)
        : h(h), tail_appender(tail_appender) {}

      virtual List operator()(List l) const {
        return cons(h, (*tail_appender)(l));
      }
    };

    return new Function1S(hd(l), tail_appender);
  }
}



// Examples.
#include <iostream.h>

// Print a list.
ostream&
  operator<<(ostream& os, List l)
{
  os << '[';
  if (!null(l)) {
    os << hd(l);
    for (List m = tl(l); !null(m); m = tl(m)) {
      os << ", " << hd(m);
    }
  }
  return os << ']';
}

-- 
Franklin Chen                     mailto:chen+@cs.cmu.edu
Graduate Student                  http://www.cs.cmu.edu/~chen/
Computer Science Department       Wean Hall 8218
Carnegie Mellon University


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]