Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: vtable sharing in cfront Message-ID: <9882@alice.UUCP> Date: 11 Sep 89 12:02:47 GMT References: <1250003@hpclove.HP.COM> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 37 In article <1250003@hpclove.HP.COM>, mnm@hpclove.HP.COM (Michey Mehta) writes: > I recently took a C++ course at UC Santa Cruz which was taught by > Stroustrup. During this course, he mentioned that if a class needs a > virtual function table, this table is defined in only one file (this > is the file which contains the definition of the first virtual member > function); all other files will just have an extern declaration of > this vtable. > 1. He also mentioned a corner case in which multiple vtable > definitions might still be emitted for the same class; does anyone > know what this corner case is? Cfront 2.0 lays down the definition of the vtable in the compilation that contains the definition (not declaration) of the first function in the class that is virtual and not inline. If there is no such function, multiple vtable definitions might still be emitted. For example, a class all of whose virtual functions are inline. This is a slight oversimplification. Another case is a class whose first virtual function is inline but is not declared inline until later: class X { public: virtual void f(); }; inline void X::f() { } > 2. In light of this feature, what do the +e0 and +e1 options do > in 2.0? They control placement of vtables for the cases where cfront cannot confidently figure out what to do unassisted. -- --Andrew Koenig ark@europa.att.com