jeff@contex.UUCP (Jeff Carey) (03/16/91)
I am using: System release: IRIX Release 4D1-3.3.1 C++ release: S4-C++-2.0 Software Option: C++ Translator Version 2.0 on a Silicon Graphics PI. Here is some code that illustrates a bug that I ran into recently. The bug has to do with "some_const" being a 'const'; the bug disappears when "some_const" is a '#define' macro. ---------------------- beginning of test.c++ code ---------------------------- #define BUG 1 #if BUG const int some_const = 0; #else #define some_const 0 #endif class V { public: V(); V(int); }; class A : virtual public V { public: A(int); }; class B { public: B(int); }; class C : public A, public B { public: C() : V(0), A(some_const), B(0) {} }; ----------------------------- end of test code ------------------------------- The code does not compile when "some_const" is a 'const'. Ouch --- jeff p.s. IMPORTANT NOTE: I assume the SGI (AT&T) bug fixers know that currently this compiler will not accept a 'virtual base class' unless it has a 'default initializer' declared; this is strange, because you can get around having to actually define the function in most (all) cases -- just declare it ?!!! By the way, this is why I have "V::V()" declared above; ideally, I would not have had it there. UNIX System V AT&T C++ Language System Release 2.0, Product Reference Manual, Select Code 307-146, section 12.6.2, p. 82, states that, and I paraphrase, "virtual base classes must have a default constructor or no constructor [only] if the constructor of a most derived class does not specify a mem-initializer for a virtual base class." I know the ARM talks about this too, but I didn't take the time to look it up, sorry. Geez --- jeff -- ------------------------ Jeff Carey contex!jeff@uunet.uu.net