TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: RON BASS
from: JERRY COFFIN
date: 1997-04-10 00:05:00
subject: Multithreading member-functions

On (08 Apr 97) Ron Bass wrote to Jerry Coffin...
 RB> Hello Jerry!
Hi Ron, it's been a while...
 DM> I thought that RTTI _could_ do this for pointers to void.
 JC> Some looking in the standard shows that I was dead wrong.  You
 JC> should be able to use a dynamic_cast to do the job.  I'm still
 JC> not sure how the compiler can ensure that it'll work, but I
 JC> guess that's its problem.
 RB> IIRC, the draft standard specifies that RTTI is only available for
 RB> classes that have at least one virtual function.  If so, it's fairly
 RB> clear that the compiler only has to go to the memory pointed to by the
 RB> original void pointer, look at the "standard" offset in the (presumed)
 RB> object for the vtable pointer, and then determine if the data at that
 RB> offset is a pointer that points to a true vtable.
The problem is that if the pointer isn't to the right kind of class at
all in the first place.  If the compiler attempts to dereference it,
that could produce all sorts of problems all by itself.
Worse, how can it determine whether or not what's pointed at is a true
vtable or not?  If it's not, the code has to give a NULL pointer.
However, anything it has in memory that it uses to identify a vtable, I
can (accidentally or otherwise) have in memory otherwise as well, and my
pointer will be mis-identified as a pointer to a class, even though it's
not.
The only way I can see to be absolutely certain about this is to always
keep a table of all objects that have been created, and search for the
passed pointer in that table.  Offhand, this sounds slow and memory
hungry at best...
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.