g++ looses an entire class.

Scott A Crosby crosby@qwes.math.cmu.edu
Thu Dec 3 20:52:00 GMT 1998


Hello, EGCS 1.1 prints out wierd error messages on the following code:

THe error message remains unchanged when the virtual keyword is removed
from Simple::foo()

The error message is meaningless and confused me for a while. Observing
the object files, in the longer case, it appeared that g++ is losing the
entire class (at least no output symbols were emitted for any class
member.)



# g++ --version
egcs-2.91.57
# g++  -Wall -g -DALL_DBG  -I. -Iincludes/ -o /tmp/nuke  model_trivial.cpp
/tmp/ccgVb36C.o: In function `main':
/root/Documents/programming/classes/indep_study/model_trivial.cpp:48:
undefined reference to `Simple::Simple(int)'
/root/Documents/programming/classes/indep_study/model_trivial.cpp:49:
undefined reference to `Simple::~Simple(void)'
/root/Documents/programming/classes/indep_study/model_trivial.cpp:49:
undefined reference to `Simple::~Simple(void)'



--------------------- model_trivial.cpp -------------------------------
class Model {
public:
  Model (int  num) :
    num(num) {};
  virtual ~Model();
  virtual void foo() =0;
protected:
  int    num;
};

class Simple : public Model {
public:
  Simple(int n) : Model(n) {};
  ~Simple();
  
  virtual void foo ();
};



main () {
  Simple n(1);
  return 1;
}







More information about the Gcc-bugs mailing list