home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!brunix!brunix!sdm
- From: sdm@cs.brown.edu (Scott Meyers)
- Subject: Re: inline virtual functions
- Message-ID: <1992Sep15.185443.21007@cs.brown.edu>
- Sender: news@cs.brown.edu
- Organization: Brown University Department of Computer Science
- References: <1992Sep15.023336.1403@cs.brown.edu> <1992Sep15.152147.12121@taumet.com>
- Date: Tue, 15 Sep 1992 18:54:43 GMT
- Lines: 38
-
- I originally wrote:
-
- | >I was involved in a discussion of this issue today when it was suggested
- | >that compilers should generate only a single copy of an out-of-line virtual
- | >function, and that the single translation unit in which the function
- | >definition should be generated should be the same as the one containing the
- | >class's vtbl. This seems sensible to me, so I was wondering: is there some
- | >reason why compiler implementers don't do this?
-
- Mike Ball responded:
-
- | No. In general, that's what will happen. Both cfront and our own compiler
- | do exactly that in the case above.
-
- My tests did not indicate that that was the case, but then Mike reminded me
- that when *all* the virtual functions in a class are inline, the vtbl is
- replicated in each translation unit. (cfront offers compiler switches to
- avoid this problem). When I reexamined my test cases, I discovered that
- I'd made all my virtual functions inline, hence the behavior I'd seen was
- more pathological than typical. In short, Mike is right and I was wrong,
- at least as regards cfront. (However, it still seems to be the case that
- g++ generates a static copy of inline virtuals for every file that sees
- their definition, but perhaps I've again overlooked something.)
-
- I apologize for the misinformation I posted earlier. Thanks to Mike Ball
- for pointing out the error of my ways.
-
- Scott
-
-
-
-
-
-
-
-
- -------------------------------------------------------------------------------
- What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."
-