Re: C++ virtual function calls

joe@sanskrit.ho.att.com (Joe Orost)
Mon, 30 Oct 1995 13:21:02 GMT

          From comp.compilers

Related articles
C++ virtual function calls tim@franck.Princeton.EDU (1995-09-29)
Re: C++ virtual function calls cliffc@ami.sps.mot.com (1995-10-05)
Re: C++ virtual function calls dlmoore@ix.netcom.com (1995-10-14)
Re: C++ virtual function calls genew@mindlink.bc.ca (1995-10-23)
Re: C++ virtual function calls cliffc@ami.sps.mot.com (1995-10-25)
Re: C++ virtual function calls joe@sanskrit.ho.att.com (1995-10-30)
Re: C++ virtual function calls jplevyak@violet-femmes.cs.uiuc.edu (John B. Plevyak) (1995-11-09)
Re: C++ virtual function calls cliffc@ami.sps.mot.com (1995-11-05)
Re: C++ virtual function calls martelli@cadlab.it (1995-11-05)
Re: C++ virtual function calls bothner@cygnus.com (Per Bothner) (1995-11-06)
C++ virtual function calls fjh@cs.mu.OZ.AU (1995-11-12)
Re: C++ virtual function calls jplevyak@pink-panther.cs.uiuc.edu (1995-11-16)
| List of all articles for this month |

Newsgroups: comp.compilers
From: joe@sanskrit.ho.att.com (Joe Orost)
Keywords: C++, optimize
Organization: AT&T
References: 95-10-029
Date: Mon, 30 Oct 1995 13:21:02 GMT

I don't think it is legal to hoist the virtual function lookup
out of the loop:


for( ...) {
p->virt_func();
}


because "p" is passed to virt_func as "this", and therefore the
function could change the subtype of "p", causing a different
function to be called next time around the loop!


                                                                regards,
                                                                joe


--
Full Name: Joseph M. Orost
EMail: joe@babel.ho.att.com, attmail!orost
Organization: AT&T Bell Laboratories: Software Migration & Tools
SurfaceMail: 943 Holmdel Rd.; Cruz Plaza; Holmdel, NJ 07733
Phone: +1 (908) 946-1115
Fax: +1 (908) 946-9146
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.