Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!usc!apple!ames!amdcad!sun!athena1!williamt From: williamt@athena1.Sun.COM (William A. Turnbow) Newsgroups: comp.lang.c++ Subject: Re: Is this a bug ? Message-ID: <134460@sun.Eng.Sun.COM> Date: 14 Apr 90 14:04:57 GMT Sender: news@sun.Eng.Sun.COM Reply-To: williamt@sun.UUCP (William A. Turnbow) Lines: 26 In article <10259@shlump.nac.dec.com> nadkarni@ashok.dec.com writes: > >Am I doing something wrong or is this a bug in the compiler ? It appears >as though the compiler tries to optimize by not copying the virtual table >function pointer when assigning an object to another. Unfortunately, >in this case it does not work. The compiler is Zortech C++ 2.06. >I expected to see the output ------ Your program doesn't even compile on our compiler (AT&T 2.0.02). It yields the following: "tst8h.C", line 18: error: member AB::b of class B with constructor in union "tst8h.C", line 18: error: member AB::c of class C with constructor in union "tst8h.C", line 18: error: member AB::a of class A with constructor in union 3 errors Just a guess, but there is a virtual field that gets auto initialized when you declare an instance of the class. By trying to do a union, there would be three different constructors to call for the same memory location, resulting in indeterminate behavior. But this is just a guess. -wat- *** We felt the effects of herb were so dangerous that it was better to lie to the american public to save them rather than tell them the truth -- Partnership for a Drug Free America