rae@gpu.utcs.toronto.edu (Reid Ellis) (11/01/90)
MPW CFront 1.0b1 (9/21/89; AT&T 2.0) does not flag changing the storage class of an overridden virtual method as an error. Executing the resulting code gives bogus values for any parameters reference through the virtual mechanism. Included below is code that illustrates this. #include <stream.h> struct base { virtual int method(int); virtual int virtual_method(int) = 0; private: int qx; }; struct derived : base { static int virtual_method(int); private: static int qvlp; }; int base::method(int v) { int dv = virtual_method(v); cout << form("base::method v is %d and virtual_method(v) is %d\n", v, dv); return v+10; } int derived::virtual_method(int v) { cout << form("derived::virtual_method v is %d\n", v); return v+100; } main() { derived d; d.method(1); d.virtual_method(2); return 0; } // output is as follows: // // derived::virtual_method v is 7365176 // base::method v is 1 and virtual_method(v) is 7365276 // derived::virtual_method v is 2 -- Reid Ellis 264 Broadway Avenue, Toronto ON, M4P 1V9 Canada rae@gpu.utcs.toronto.edu || rae%alias@csri.toronto.edu || +1 416 487 1383
jgro@lia (Jeremy Grodberg) (11/06/90)
In article <rae.657414585@earth> Reid Ellis <rae@gpu.utcs.toronto.edu> writes: >MPW CFront 1.0b1 (9/21/89; AT&T 2.0) does not flag changing the >storage class of an overridden virtual method as an error. MPW 3.1b1 (aka MPW CFront 1.0b1) is an old and known buggy version of C++. Many serious bugs existed in that version, as it was released before AT&T CFront 2.0 (on which it is based) was really finalized. Unfortunately, until recently, most people did not have access to anything better from Apple. However, Apple did finally get around to releasing a production quality C++, and so, hopefully, put to rest bugs such as reported by Mr. Ellis. The current version of C++ for the Macintosh under MPW is C++ 3.1 (final), which is available from APDA at 800 282 2732. It is the only non-beta release ever made for MPW C++. Bugs in older (beta) versions are not particularly interesting anymore. Note that MPW C++ 3.1 is based on AT&T CFront 2.0. The 3.1 version number means that it works with the MPW 3.1 environment, not that it is derived from AT&T CFront 3.1 (I wish). -- Jeremy Grodberg "I don't feel witty today. Don't bug me." jgro@lia.com