home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13702 < prev    next >
Encoding:
Text File  |  1992-09-15  |  1.9 KB  |  50 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!brunix!brunix!sdm
  3. From: sdm@cs.brown.edu (Scott Meyers)
  4. Subject: Re: inline virtual functions
  5. Message-ID: <1992Sep15.185443.21007@cs.brown.edu>
  6. Sender: news@cs.brown.edu
  7. Organization: Brown University Department of Computer Science
  8. References: <1992Sep15.023336.1403@cs.brown.edu> <1992Sep15.152147.12121@taumet.com>
  9. Date: Tue, 15 Sep 1992 18:54:43 GMT
  10. Lines: 38
  11.  
  12. I originally wrote:
  13.  
  14. | >I was involved in a discussion of this issue today when it was suggested
  15. | >that compilers should generate only a single copy of an out-of-line virtual
  16. | >function, and that the single translation unit in which the function
  17. | >definition should be generated should be the same as the one containing the
  18. | >class's vtbl.  This seems sensible to me, so I was wondering: is there some
  19. | >reason why compiler implementers don't do this?
  20.  
  21. Mike Ball responded:
  22.  
  23. | No.  In general, that's what will happen.  Both cfront and our own compiler
  24. | do exactly that in the case above.
  25.  
  26. My tests did not indicate that that was the case, but then Mike reminded me
  27. that when *all* the virtual functions in a class are inline, the vtbl is
  28. replicated in each translation unit.  (cfront offers compiler switches to
  29. avoid this problem).  When I reexamined my test cases, I discovered that
  30. I'd made all my virtual functions inline, hence the behavior I'd seen was
  31. more pathological than typical.  In short, Mike is right and I was wrong,
  32. at least as regards cfront.  (However, it still seems to be the case that
  33. g++ generates a static copy of inline virtuals for every file that sees
  34. their definition, but perhaps I've again overlooked something.)
  35.  
  36. I apologize for the misinformation I posted earlier.  Thanks to Mike Ball
  37. for pointing out the error of my ways.
  38.  
  39. Scott
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. -------------------------------------------------------------------------------
  49. What do you say to a convicted felon in Providence?  "Hello, Mr. Mayor."
  50.