Path: utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!RESEARCH.ATT.COM!europa!ark From: europa!ark@RESEARCH.ATT.COM Newsgroups: gnu.g++ Subject: (none) Message-ID: <8903210206.AA20438@prep.ai.mit.edu> Date: 21 Mar 89 02:23:09 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 20 One difficulty has not yet been mentioned in making sizeof respect virtual functions. Suppose D is derived from B and bp is a B*. Then bp can `really' be pointing either to a B or to a D. One might think that sizeof(*bp) should be able to tell which. However, the C language definition says that if the argument of sizeof() is an expression, that expression is not evaluated! It is obviously impossible to tell whether bp points at a B or a D without evaluating it. You might think it doesn't really matter -- after all, how can it hurt to evaluate an expression like *bp to figure out the value of sizeof(*bp)? But what about sizeof(f()), where f is a function returning a B*? You can't call f, or it wouldn't be C -- and it would be very sleazy to say that sizeof evaluates its argument if virtual functions are involved but not otherwise. No, it seems that this kind of facility must be named something else.