niklas@appli.se (Niklas Hallqvist) (10/30/90)
I've bumped into yet another peculiarity with G++ 1.37.1 (+ some of 1.37.2) generating 386 code. Consider the following code: class BASE_1 {}; class DERIVED_1 : public BASE_1 {}; class BASE_2 { public: virtual void f() = 0; }; class DERIVED_2 : public BASE_1, public BASE_2 {}; class DERIVED_3 : public DERIVED_1, public DERIVED_2 { public: void f() {} }; int main(void) { DERIVED_3 object; object.f(); } This compiles fine, but when ran, generates a memory fault when calling object.f(). If I instead derive from BASE_1 virtually, the error goes away. What I don't understand is: How can the BASE_1 part(s) of DERIVED_3 disturb the virtual call of DERIVED_3::f()? Is it illegal C++? How does cfront & G++ 1.37.2 handle this code? Is it just for the 386 G++ 1.37.1 generates this bad executable? BTW. In an earlier posting I reported, what I thought to be a bug with G++ concerning a pure virtual destructor. When I thought about this, I suddenly realized that a destructor hardly can be pure, since all base classes destructors (the pure ones too!) gets called when an object is destroyed. Is this fact correct? (Thanks to Paul Vaughan giving me a hint about this!) If it is, shouldn't pure virtual destructors be illegal? Thanks, Niklas -- Niklas Hallqvist Phone: +46-(0)31-40 75 00 Applitron Datasystem Fax: +46-(0)31-83 39 50 Molndalsvagen 95 Email: niklas@appli.se S-412 63 GOTEBORG, Sweden mcsun!sunic!chalmers!appli!niklas